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 trialBerluis Cabrera
Courses Plus Student 443 PointsHow can i convert the argument of a function to float?
How can I do it??
def add(name, number):
return float(name+number)
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHi Berluis,
You're on the right track, but you would need to use float()
on each variable in the return statement. You have to do it this way, because the float()
function takes a single argument to convert. The code you have above is placing two values inside.
So, instead of
return float(a + b)
You will need to do each one on its own
return float(a) + float(b)
Hope that helps. :)
Keep Coding!
Berluis Cabrera
Courses Plus Student 443 PointsBerluis Cabrera
Courses Plus Student 443 PointsThanks a lot man