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

Fin Muir
Fin Muir
1,108 Points

I need help with floats

I'm stuck

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

1 Answer

Ben Reynolds
Ben Reynolds
35,170 Points

This challenge doesn't need anything to be converted to a float, you can just return the sum of the two variables (you won't need parentheses around the return statement).

But, if you do need to cast something to a float in the future it would look like this:

num = 10
num_to_float = float(num)