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

Amr AbdelNasser
Amr AbdelNasser
1,745 Points

float function returns a ValueError

Ive tried the code on workspace and it works fine. Cant figure out what the problems is here.

trial.py
def add(e,r):
    return(float(e+r))
add(3,4)

1 Answer

Steven Parker
Steven Parker
231,271 Points

Depending on what values you test it with, it might seem to "work", but it's not doing the job asked for in the instructions.

To meet the challenge requirements, you'll need to convert each argument to "float" individually, before you add them.

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