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

What am I doing wrong here?

def add(num1, num2) : float(num1) float(num2) Result = num1 + num2 return(Result) add(1,2)

trial.py
def add(num1, num2) :
    float(num1)
    float(num2)
    Result = num1 + num2
    return(Result)
add(1,2)

1 Answer

Steven Parker
Steven Parker
231,275 Points

Calling "float" doesn't change the number it works on, it just returns the converted result. So doing it by itself isn't very useful.

But you could store the result back into the variable:

    num1 = float(num1)

Also, the challenge only asks you to define the function, you don't need to call it yourself.