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

Raghunath Ramaiah
Raghunath Ramaiah
496 Points

exceptions.py

I coded the script as same as kenneth as below but i get error in workspases. Please help and also getting same error for all the functions which i created

try: count = int(input("please give me a number? ")) except ValueError: print("that is not number!" else: print("Hi " * count)

AND GETTING THE BELOW ERROR

python exceptions.py
File "<stdin>", line 1
python exceptions.py
^
SyntaxError: invalid syntax

3 Answers

Hey Raghunath! Please use the markdown cheat sheet below the "add an answer" area. This shows how to format code which makes it a lot easier to debug.

From what I can see tho you have a couple of errors. One is that you didn't close one of your print statements, and you also are adding an else statement after your exception, which you shouldn't do.

Raghunath Ramaiah
Raghunath Ramaiah
496 Points

Please see the exceptions.py videos from Kenneth videos with the same code. But for kenneth its running successfully where as i type in the same and try to run i get the error, this is not only for one program it happens to me for simple print function stored in a file and try to run.

Raghunath Ramaiah
Raghunath Ramaiah
496 Points

Thank You its working now as i was running from interpreter and i did a exit() and ran the program from console it ran smoothly.