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 trialannikaheflin
577 PointsPlease help I don't get it
The float isn't working and nice isn't defined. If you know how to help please do so.
def add(nice, cool):
return nice + cool
str_to_float = float(nice), float(cool)
3 Answers
Ben Reynolds
35,170 PointsThe key is in this part of the instructions: "Convert your arguments to floats before you add"
Antonio De Rose
20,885 Pointsdef add(nice, cool):
return nice + cool
str_to_float = float(nice), float(cool) #you cannot actually do this, separating 2 variables and placing into a variable
#again another is to convert the variables to float, before totalling
behar
10,799 PointsYup, to elaborate, your returning nice + cool before you have converted them to floats. You can actually return the total and covert the numbers to a float on the same line like this:
def add(num1, num2):
return float(num1) + float(num2)