NameError: name 'raw_input' is not defined [duplicate]
Asked Answered
M

1

61

I'm a seventh grade programmer so I may be missing a lot of things in this program, but for my coding club my instructor asked us to make a guess the number game. I have very limited knowledge on this subject, since I've only attended four classes. Anyway, when I run this program in Python IDLE 3.5 this is what it says:

Traceback (most recent call last):
File "C:\Users\morrris\AppData\Local\Programs\Python\Python35-32\guess_that_number.py", line 7, in <module>
name= raw_input()
NameError: name 'raw_input' is not defined

I tried changing the code, but it seems to not like the raw_input().

Motheaten answered 3/2, 2016 at 4:26 Comment(3)
Python 3.5 doesn't have raw_input. It has input()Villosity
In the future, when you post code, try to post the minimum needed to exhibit the symptom you are asking about. In this case, name= raw_input() is quite sufficient. See stackoverflow.com/help/mcveHertford
I'm sorry, I didn't knowMotheaten
C
118

For Python 3.x, use input(). For Python 2.x, use raw_input(). Don't forget you can add a prompt string in your input() call to create one less print statement. input("GUESS THAT NUMBER!").

Castoff answered 3/2, 2016 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.