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 trialHanifah W
395 PointsFloat, float on - changing function to float before adding
I also tried it as so:
def add(num1,num2): return(float(num1 + num2))
AND
def add(num1,num2): float() return(num1 + num2)
this seems pretty straight forward? What am I doing wrong. I am converting the arguments into floats before adding. No?
def add(float(num1,num2)):
return(num1 + num2)
2 Answers
Jennifer Nordell
Treehouse TeacherWe don't do the conversion of the floats in the definition of the parameters of the function. Instead we take the float of each number and add it together. Here's my end code to clarify what they're looking for:
def add(x,y):
try:
return float(x) + float(y)
except ValueError:
return None
Note: this is for challenge 3 of 3.
Gianmarco Mazzoran
22,076 PointsHi,
the float
function takes only **one argument.
The challenge is asking you to return the floated version of your arguments so you need to do something like this:
def add(num1, num2):
return float(num1) + float(num2)