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

Cameron Kjellerson
PLUS
Cameron Kjellerson
Courses Plus Student 426 Points

How do I add the float() function to this?

Not sure where the proper input for the float() function is. I have tried a couple different spots but they all seem to be wrong.

trial.py
def add(num1, num2): 
    return(float(num1 + num2))

1 Answer

Aaron Nolan
Aaron Nolan
5,714 Points

You need to use float() on each number individually like so :

return float(num1) + float(num2)

Hope this helps and happy coding :)