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

wesley jackson
wesley jackson
2,436 Points

Challenge Task 3/3 Try and Except

Only when last 2 float lines are added then it seems like there is an error as the block works in isolation. I would appreciate being pointed in the right direction. Thank in advance WJ

def add(p1,p2):
        p1 = int(input("Give me a number: "))
        p2 = int(input("Give me a second number: "))

    except ValueError:
        print("That's not a number dude!")
        return None

p1 = float(p1)
p2 = float(p2)

1 Answer

Steven Parker
Steven Parker
230,230 Points

Your answer seems very different from the challenge instructions.

There's nothing in the challenge about prompting, taking input, printing messages, or integer conversions. Did you copy some code from a different assignment? Plus you have some code that is outside of the function.

You'll need to go back to where you passed task 2, and carefully follow the instructions to add only those features the challenge expects. Don't do anything extra!

wesley jackson
wesley jackson
2,436 Points

Hmmm, I see. Thank you, Steven, I will give it another go but I did use Python documentation to assist me and the tutorials as I did not really understand the instructions; I just tried to get the code block to work which I thought would suffice and this I could only do by running a program. :-( seems I am overthinking this right?

Thank you for your swift response. WJ