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

Python Floats Help!

Having trouble converting my arguments into floats!

trial.py

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
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