Raw_input method is not working in python3. How to use it?

0 votes
I am always getting an error whenever I am using raw_input method, whereas in pthon2, its running fine. What's the issue?
May 4, 2018 in Python by anto.trigg4
• 3,440 points
764 views

1 answer to this question.

0 votes

raw_input is not supported anymore in python3. Instead of that, you can simply use input(). It will serve the same functionality to take input from the user. Example:

name=input("Enter your name") 
print("My name is", name)
answered May 4, 2018 by aayushi
• 750 points
I agree i ran the raw_input command on python 3 and i was getting an error as follows;

ython 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> target_int = raw_input("How many integers?")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'raw_input' is not defined

and when i changed it from raw_input to input the same code worked in python 3

and got the OUTPUT as follows

xe "c:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/Hello World.py"
38-32/Hello World.py"
You must enter an integer

What it shows in python 3 the input command exists and raw_input is defunct or non existing command

Related Questions In Python

0 votes
3 answers
+4 votes
7 answers
0 votes
2 answers

how to use print statement in python3?

The print statement has been replaced with a print() ...READ MORE

answered Jul 16, 2018 in Python by Mrunal
• 680 points
116 views
+1 vote
1 answer

How is raw_input() and input() in python3.x?

raw_input() was renamed to input() so now input() returns the exact string ...READ MORE

answered Oct 30, 2018 in Python by Priyaj
• 57,530 points
108 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 939 views
0 votes
0 answers
0 votes
1 answer

What is the use of raw_input function in Python?

raw_input fuction is no longer available in ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
200 views
+2 votes
11 answers