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 trialtonypitkin2
Courses Plus Student 1,950 PointsDo you need to declare a float on a per-value level?
I was trying to do the following:
def add(num1, num2):
return float(num1, num2)
But it seems that is not a thing...
Instead it appears I need to do:
def add(num1, num2):
return float(num1) + float(num2)
Does this all seem accurate? Is there a way to clean this up? I'm imagining a scenario where I could have hundreds of these and adding each of those would get old real quick...
1 Answer
Steven Parker
231,269 PointsYou're right, float just converts one number.
If you had many items to convert, you'd probably use a loop so you'd still only have a few lines of code.