written 2.0 years ago by |
Solution:
The function raw input() presents a prompt to the user gets input from the user, and returns the data input by the user in a string.
We call this function to tell the program to stop and wait for the user to input the values.
This differs from input() in that the latter tries to interpret the input given by the user; it is usually best to avoid input() and stick with raw input() and custom parsing/conversion code.
For example 1:
With String as Input,
Output:
Example program in Python2:
# python program to demonstrate raw_input() function test_raw = raw_input("Enter the string: ") print 'The input string is: ', test_raw
The raw input() function works only in python2 and does not work in python3. python2 supports both input () and raw input() functions but python3 supports only input() function.
But in python2 the function takes the value and the input you enter will taken as it is without modifying its types.