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

Answer from heinst on Stack Overflow
🌐
Career Karma
careerkarma.com › blog › python › python nameerror: name ‘raw_input’ is not defined solution
Python NameError: name ‘raw_input’ is not defined Solution | CK
December 1, 2023 - Traceback (most recent call last): ... not defined · Our code returns an error. The error message tells us we are referencing a value that does not exist. Because we are using Python 3.x to run our program, raw_input() does not ...
🌐
PsychoPy
discourse.psychopy.org › coding
NameError: name 'raw_input' is not defined when debugging in PyCharm - Coding - PsychoPy
January 31, 2022 - When I run the code normally, everything works fine however if I put a break point anywhere and run the debugger it throws me this error: Traceback (most recent call last): File " ", line 25, in NameError: name 'raw_input' is not defined python-BaseException This is the ...
🌐
Reddit
reddit.com › r/learnpython › nameerror: name raw_input is not defined
r/learnpython on Reddit: NameError: name raw_input is not defined
April 2, 2021 -

I'm making an interactive menu and this problem apear and I don't know how to fix it, can soemeone please tell me how to fix it or tell me another approach for the error not to apear?

def funcion_uno():
print('Esta es la funcion uno')
def funcion_dos():
print('esta es la funcion dos')

if __name__ == '__main__':
salir = False
print('\033[1;32;40m Menu interactivo de Daft Punk')

mensaje = 'Ingrese la opcion deseada: '

menu = { 'a)': funcion_uno , 'b)': funcion_dos }

while not salir:
print('-'*len(mensaje))
print(mensaje)
for opcion, funcion in menu.iteritems():
print(opcion)
respuesta = raw_input('\nOpcion: ').lower()
salir = respueta == 'exit()'
else:
print('Hasta luego')

🌐
Reddit
reddit.com › r/learnpython › spyder python ide throws 'raw_input' is not defined error, code works ok on python tutor
r/learnpython on Reddit: Spyder Python IDE throws 'raw_input' is not defined error, code works ok on python tutor
April 24, 2018 -

This is Python 2.7 and I'm trying to understand why one IDE throws an error and the other doesn't.

If I run the following code under Spyder:

name = raw_input("What is your name? ")
birthdate = raw_input("What is your birthdate? ")

age = input("How old are you?")

print("%s was born on %s" % (name, birthdate))
print("Half of your age is %s" (age /2 ))

I then get

NameError: name 'raw_input' is not defined

If I run the same code under pythontutor.com, the code runs without error.

Just wondering why there is a difference between these IDEs and how to fix it under Spyder.

thanks

🌐
Quora
quora.com › How-do-I-solve-name-error-name-raw_input-is-not-defined-in-Python
How to solve “name error: name 'raw_input' is not defined” in Python - Quora
I encountered the same issue when ... 3, it's been replaced with input(). So, to fix the error, simply replace raw_input() with input() in your code, and it should work as expected....
🌐
GitHub
github.com › sparkfun › Graphical_Datasheets › issues › 5
NameError: name 'raw_input' is not defined · Issue #5 · sparkfun/Graphical_Datasheets
May 10, 2021 - Make sure the python script is in the same folder as the file. Traceback (most recent call last): File "C:\Users\Michael\Documents\Graphical_Datasheets\tagscript.py", line 107, in <module> myfile = raw_input("Enter file name without the .csv extension (eg. ESP8266/Thing): ") NameError: name 'raw_input' is not defined...
Published   May 10, 2021
Author   pixelwaster
Find elsewhere
🌐
PythonAnywhere
pythonanywhere.com › forums › topic › 32318
Resetting Web2py Administrator password - "raw_input not defined" error : Forums : PythonAnywhere
January 19, 2023 - I solved this issue. The raw_input function is not needed. ... Glad to hear that you made it work! fjl | 5397 posts | PythonAnywhere staff | Jan. 20, 2023, 10:01 a.m.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-nameerror-name-raw-input-is-not-defined
NameError: name 'raw_input' is not defined in Python [Fixed] | bobbyhadz
Make sure to replace all calls to the raw_input() function with input() in Python 3. The input() function takes an optional prompt argument and writes it to standard output without a trailing newline.
🌐
Edureka Community
edureka.co › home › community › categories › python › nameerror name raw input is not defined
NameError name raw input is not defined | Edureka Community
September 3, 2018 - I'm a seventh-grade programmer so I may be missing a lot of things in this program, but for my ... code, but it seems to not like the raw_input().
🌐
Itsourcecode
itsourcecode.com › home › nameerror name ‘raw_input’ is not defined
Nameerror name 'raw_input' is not defined [SOLVED]
May 3, 2023 - Unfortunately, the raw_input() ... raised an nameerror name ‘raw_input’ is not defined, because the function does not exist in that version of Python....
🌐
Sololearn
sololearn.com › en › Discuss › 841578 › raw_input-not-defined
raw_input not defined | Sololearn: Learn to code for FREE!
I am trying to create a program that would require user input in the console using raw_input, but when I use it like so: raw_input = ("Enter your age") It returns the error "raw_input not defined" Can someone please explain how to use raw_input? Thank you so much :) ... raw_input() is a Python 2 command, for Python 3 (implemented in Sololearn's Code Playground) the right command is input()
🌐
Python Forum
python-forum.io › thread-28312.html
Going thru tutorials..."NameError: name 'raw_input' is not defined"
I'm a total newbie, wrote machine code for years at GE, Digital Communications stuff. Off to try to learn Python. In going thru the tutorials in one of the 'dummies' books, they have an example using raw_input(), and I get this error message Error:'N...
🌐
Reddit
reddit.com › r/learnpython › raw input function not working correctly for me
r/learnpython on Reddit: raw input function not working correctly for me
October 24, 2024 -

I have to edit this python file for one of my classes. I have the python extension by microsoft installed on vs code on mac os with the latest updates. When I try to run the program, I get this error: File "/Users/Downloads/decrypt.py", line 8, in <module>
code = raw_input(jls_extract_var)
NameError: name 'raw_input' is not defined

What could be causing this issue? It's a program already given to me by my professor that I just have to edit, but the raw input function isn't even letting me test the program.

This is the program that I need to edit, in case I may just be having a syntax or logical error.

"""
File:
Decypts an input string of lowercase letters and prints
the result. The other input is the distance value.
"""

code = raw_input("Enter the coded text: ")
distance = input("Enter the distance value: ")
plainText = ''
for ch in code:
ordValue = ord(ch)
cipherValue = ordValue - distance
if cipherValue < ord('a'):
cipherValue = ord('z') - (distance - \
(ordValue - ord('a')) - 1)
plainText += chr(cipherValue)
print(plainText)

Top answer
1 of 2
4
Where did you see raw_input documented? It hasn't been a thing since Python 2. There is no need to use it - just use input, like you do already on the following line.
2 of 2
2
Only experienced Python developers responsible for maintaining / updating old Python code should be using Python 2, which went out of support January 1, 2020 (a date much later than originally planned). The current release of Python is 3.13. The first release of Python 3 was back in 2008. raw_input in Python 2 was renamed input in Python 3. (There was an input in Python 2, but that was dropped.) It used to be the case that learning material for Python 2 was still highly relevant for Python 3, you just needed to keep a few changes in mind. However, Python 3 has advanced so much over the last few years, that learning material for Python 2 can be very limiting and teach you poor ways of doing things. If you want it though, here's a guide to some of the differences: https://www.datacamp.com/blog/python-2-vs-3-everything-you-need-to-know Revised code: code = input("Enter the coded text: ") distance = int(input("Enter the distance value: ")) # convert string to int plainText = '' for ch in code: ordValue = ord(ch) cipherValue = ordValue - distance if cipherValue < ord('a'): cipherValue = ord('z') - (distance - (ordValue - ord('a')) - 1) plainText += chr(cipherValue) print(plainText) PS. We usually use all lowercase for variable names, so, for example, plainText would be plaintext or plain_text (if you was to separate the words). Search for and read PEP8.
🌐
Its Linux FOSS
itslinuxfoss.com › home › python › nameerror: name ‘raw_input’ is not defined in python
NameError: name ‘raw_input’ is not defined in Python – Its Linux FOSS
November 29, 2022 - The “name raw_input is not defined” error arises when the user uses the “raw_input()” function in Python3. To solve this, use the simple “input()” function that takes the “prompt” value as an argument and returns the string.
🌐
Edureka Community
edureka.co › home › community › categories › python › raw input is not defined
Raw Input Is Not Defined | Edureka Community
September 17, 2018 - I'm a seventh grade programmer so I may be missing a lot of things in this program, but for my ... code, but it seems to not like the raw_input().
🌐
Python.org
discuss.python.org › python help
Printing number but when entering string showing error string not defined - Python Help - Discussions on Python.org
April 24, 2022 - a = input("enter ") print(a) #when igiving input as number it is printing but when I try to give string as input it is showing error as “string not defined”
🌐
GeeksforGeeks
geeksforgeeks.org › python › difference-between-input-and-raw_input-functions-in-python
input() vs raw_input() functions in Python - GeeksforGeeks
September 17, 2025 - It always takes input as a string, just like input() in Python 3. If you want the input in another type (e.g., integer), you need to explicitly convert it using int() or float(). ... val1 = raw_input("Enter the name: ") print(type(val1)) print(val1) ...