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 should I put as my else also is there anything else wrong?

Please I am not sure what to put as else if you could help with that and see if you can spot anything else it would be much appreciated.

trial.py
def add(nice, cool):
try:
    return float(cool) + float(nice)
except ValueError:
     return None
else:
    return cool + nice

1 Answer

I checked your code, and it throws an error because of your indentation. You need to put your code inside of the function and it passes the challenge.

def add(nice, cool):
    try:
        return float(cool) + float(nice)
    except ValueError:
        return None
    else:
        return cool + nice