Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialammar ahmed
531 Pointsstuck
Code gives an error on work space but works fine on my computer
def add(x, y):
total = float(x+y)
return(total)
2 Answers
Steven Parker
231,248 PointsThe challenge says to "Convert your arguments to floats before you add them together." The key word there is before.
If you write float(x+y)
the addition will occur first, then the result will be handed over to float.
You need to re-write it so each argument is convert to a float before they are added.
ammar ahmed
531 Pointsdef add(x,y): float(x) float(y) return(x+y)
it still gives me an error