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 5, 2018 in Python by anto.trigg4
• 3,440 points
3,356 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 5, 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
4 answers

What is a Tuple in Python and how to use it?

Tuples  are a  Unchanging sequence of values, ...READ MORE

answered Jun 21, 2020 in Python by sahil
• 500 points
1,961 views
+4 votes
7 answers
0 votes
3 answers

how to use print statement in python3?

Brackets are required to print the output. >>> ...READ MORE

answered Nov 25, 2021 in Python by anonymous
1,621 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
• 58,020 points
897 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
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
1,254 views
+1 vote
12 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP