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 The Exception to the Rule

linzhang5
linzhang5
2,398 Points

ValueError syntax error message in my own terminal

So, when I tried to execute this ValueError syntax in my own python, and input "five" as argument, I get this error message:

Traceback (most recent call last): File "exceptions.py", line 2, in <module> count = int(input("Give me a number: ")) File "<string>", line 1, in <module> NameError: name 'five' is not defined

Anyone can explain this to me? Thank you so much.

The full syntax inputted as the video shown: try: count = int(input("Give me a number: ")) except ValueError: print("That's not a number!") else: print("Hi" * count)

4 Answers

Nicolas Bassano
Nicolas Bassano
2,125 Points

Hi!

Wich version of Python do you have?

Con you post the markdowned version of the code??

I tried mine and its working.

I just used workspace, the version is 3.5.0, it seems ValueError can't be instead of other words.

Eric Ouellette
Eric Ouellette
3,332 Points

Hi,

Did you solve your problem? I have the same so if you solved it can you tell me what you did ?

Thanks

i used NameError instead of ValueError and it worked, I was using a mac terminal

Murat Kuru
Murat Kuru
1,909 Points

NameError solved my "problem" too.