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

Exhausted from this easy task.

wow, i've been trying everything possible to solve this. i think theres something wrong with my version of the account in treehouse. i swear i tried this like 50 times and i know i'm doing it right, but still get the Bummer error. Any one please help, thank you all.

trial.py
def add(a,b):
try:
    x = float(a)
    c = float(b) 
except ValueError:
    return None
else:
    return x+c

2 Answers

All of your code is correct, the only problem is your indentation. In python you need to indent the code inside a function further than the declaration, like this:

def add(a,b):
    try:
        x = float(a)
        c = float(b) 
    except ValueError:
        return None
    else:
        return x+c

Hi Connor,

Thank you so much i need to remember that indentation is a main key in Python.