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

Christopher Morris
Christopher Morris
1,050 Points

TRY Fucntion

Do I need to remove the def add(a, b)

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

1 Answer

Steven Parker
Steven Parker
231,007 Points

You probably don't want to remove your function definition.

I believe creating the function is the main point of the challenge. But for the lines below it to be considered as part of the function, they all need to be indented.

Christopher Morris
Christopher Morris
1,050 Points

i tried doing it with an indention for TRY but that still isnt working...from what I can see, they already look indented...thanks for helping by the way.. i just feel so stuck

Steven Parker
Steven Parker
231,007 Points

In your code above, the try is definitely not indented. The lines below it are but they need to be indented even further when you indent the try. Every line currently below the definition needs to be indented one level more than it currently is.