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

Juan Davin
Juan Davin
2,792 Points

What's wrong?

I cant find what's wrong with my lines of code

trial.py
def add(x,y):
    try:
        count=(x+y)
    except valueError:
        return None
    else:
        return float(x)+float(y)

1 Answer

Hey Juan,

You're really close! Here are some tips:

  1. The parentheses around x+y aren't needed.
  2. The challenge wants you to call the float function on your parameters(x, y) in the try block. So you should see count = float(x) + float(y)
  3. The 'V' in ValueError needs to be capitalized.

Hope this helps, and let me know how it went!