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

Having trouble discerning what exactly they want here. It said add a try block. Not sure what to put in it.

I know the final return(float()) section is what they want, but there's nothing specified in the directions as to what they want in the try block, and all it tells me is bummer.

trial.py
def add(x,y):
    try:
        return(float(x) + float(y))
except ValueError:
    return(None)
else:
    return(float(x) + float(y))
add(4,5)

2 Answers

Annnndddd....Yup, that was it. Thank you for that!

Garrett Hughes
seal-mask
.a{fill-rule:evenodd;}techdegree
Garrett Hughes
Python Development Techdegree Student 32,971 Points

Hey Dan,

Everything looks correct, your indentation is just off. Make sure all your statements are properly nested in your function and you should be alright.