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 trial

Python Python Basics (2015) Logic in Python Try and Except

Help! Python converting my arguments into floats?

Python floats

trial.py
def add(x,y):
    return(x + y)
a = float(x)
b = float(y)
    return(a + b)

1 Answer

remove 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.

What do you mean?

you 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.

not sure what you mean