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

jonathan arriaga
jonathan arriaga
416 Points

need help? whats wrong with my code

cant figure out whats wrong with my code

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

2 Answers

Christian Mangeng
Christian Mangeng
15,970 Points

Hi jonathan,

three issus in your code:

1) remove the colon after return

2) None always has a capital N

3) check your indentation: try, except and else should have an indentation of one tab (as these are inside the function), while the actions that follow all have one more tab, as these are inside try, except or else (so 2 tabs in total).

Hope that helps

jonathan arriaga
jonathan arriaga
416 Points

Thank you! i fixed all the issues you pointed out and i was able to solve the challenge. And thank you for the tip on the indentations they have been throwing me off

bryonlarrance
bryonlarrance
16,414 Points

Indentation is incorrect and one extra ':' after return.