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

trial task 3

help please? trial task 3

trial.py
def add(number1, number2):
    try:

    number1 = float(number1)
    number2 = float(number2)

    except ValueError:
        returne None

    return(number1 + number2)

1 Answer

Hi, there

Looking at your code you are very close!

Just some issues and mistake. First, this part from your code needs adjustment.

    try:

    number1 = float(number1)
    number2 = float(number2)

When you write try your code that is inside the try needs to be indented. Right now your two codes are not indented.

Second, the task want you to write else: so if you write else: before you write return (number1+number2) you will be spot on!

Hope this helps!

Thanks, still not getting though?

I copied your code and tried to do the challenge to see what else is wrong and I found a typo in your code. You wrote returne when it should have been return. Other than that, when I fixed your code like I mentioned it should let you pass the task.

thanks for all your help my code is still not passing can you please show me what its should look like?

Okay, Let me use your code and with comment it might be more helpful.

def add(number1, number2):
    try:
# the two codes should have an indent. Right now yours do not.
    number1 = float(number1)
    number2 = float(number2)
    except ValueError:
# you mispelled return it is  not returne! 
        returne None
# the task asks you to put else:
# also don't forget the indent return(number1 + number2) after you write else:
    return(number1 + number2)