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

Please help I don't get it

The float isn't working and nice isn't defined. If you know how to help please do so.

trial.py
def add(nice, cool):
    return nice + cool
str_to_float = float(nice), float(cool)

3 Answers

Ben Reynolds
Ben Reynolds
35,170 Points

The key is in this part of the instructions: "Convert your arguments to floats before you add"

Antonio De Rose
Antonio De Rose
20,885 Points
def add(nice, cool):
    return nice + cool
str_to_float = float(nice), float(cool) #you cannot actually do this, separating 2 variables and placing into a variable
#again another is to convert the variables to float, before totalling

Yup, to elaborate, your returning nice + cool before you have converted them to floats. You can actually return the total and covert the numbers to a float on the same line like this:

def add(num1, num2):
    return float(num1) + float(num2)