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

can't find it out

I'am not able to find out what's going wrong. Plz help

trial.py
def add(me, I):
    try:
        count = float(me + I)
        except ValueError:
            print("this is not me ")
            else:
                print("that's me")



    return float(me) + float(I)

1 Answer

josephr
josephr
18,877 Points

I think you might be confused about what they are looking for. The print statements are not necessary. You also need to be careful with your indents in Python.

You try to add the two. If that gives a value error just return None (no print necessary). If there is no ValueError, return the sum.

def add(me, I):
    try:
        count = float(me) + float(I)
    except ValueError:
        return None
    else:
        return count