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 trialTerry Joseph
Courses Plus Student 413 PointsHelp! Python converting my arguments into floats?
Python floats
def add(x,y):
return(x + y)
a = float(x)
b = float(y)
return(a + b)
1 Answer
Amitesh Singh Baghel
2,256 Pointsremove float from 'float(x)' and change the line to 'a = y'. float(var) is used to convert the value stored in the variable to float. That is the reason why you are facing the problem.
Terry Joseph
Courses Plus Student 413 PointsTerry Joseph
Courses Plus Student 413 PointsWhat do you mean?
Amitesh Singh Baghel
2,256 PointsAmitesh Singh Baghel
2,256 Pointsyou can solve the problem in 2 ways http://prntscr.com/fkynlp or http://prntscr.com/fkyoa2 The thing is float(variable _name) is used to convert variable_name into float. That is why you are having the problem, example if u write float(3) the value u will get is 3.0.
Terry Joseph
Courses Plus Student 413 PointsTerry Joseph
Courses Plus Student 413 Pointsnot sure what you mean