What is the difference between input() and raw_input() in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between input() and raw_input() in python?

please explain with suitable example

26th Nov 2016, 6:24 AM
UMANG BHATIA
UMANG BHATIA - avatar
3 Answers
+ 1
in python 2.x, input() return python datatype based on user input, eg. it return a list when user enter [1,2,3]. while raw_input() return raw string. It return as string '[1,2,3]' when user enter [1,2,3]. in python 3.x, input() is equivalant to raw_input() of python 2.x.
26th Nov 2016, 12:20 PM
skycc
skycc - avatar
0
Input() is from the newer version of python, 3.x. raw_input is from versions 2.x.
26th Nov 2016, 6:44 AM
Grady
Grady - avatar
0
ok thank you
26th Nov 2016, 8:32 AM
UMANG BHATIA
UMANG BHATIA - avatar