Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Python Floats Help!

Having trouble converting my arguments into floats!


Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi, Terry! I'd be interested to know what you've tried thus far that's failing. This will help us to explain better where you're going wrong and ultimately be a better learning opportunity for you :sparkles:

will do!

2 Answers

Dario Bahena
Dario Bahena
10,697 Points
# float() converts and int to a float
# float(9)  is 9.0   float(9.0) is still 9.0
# lets say x is the int 9 and y is the int 7
def add(x, y): # x and y are the arguments
    #          9.0      +     7.0
    return float(x) + float(y)

i figured it out can you help me with the next step

Dario Bahena
Dario Bahena
10,697 Points

Hint: use float()

float(9) <-- that is now 9.0 which is a float, fancy for a number with a decimal.

So i should make my arguments ints? or how do i make my arguments into floats

def add(x,y): return(x + y) is what i have how can i make this a flaoat