Raw_Input() Is Not Defined

Makailah Morris picture Makailah Morris · Feb 3, 2016 · Viewed 159.2k times · Source

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().

Answer

heinst picture heinst · Feb 3, 2016

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!").