Python raw_input read input from keyboard

By | 2018-03-26T18:30:30+00:00 June 2nd, 2017|Python|0 Comments

In this tutorials, I am going to show you how to read input from the keyboard in python.

Python raw_input :

Python raw_input is a python function used to read the input from keyboard in the form of String.

raw_input() Example :

Sample.py

x=raw_input("Enter any value : ")
print x
print type(x)

If we use raw_input() function, what ever the type of data we given as an input, it will internally converted as string type. We can check the type of data using type(x) function.

Note : The raw_input() function has been deprecated in python 3.x instead we can use python input() function.

Lets run the above sample code :

$ python sample.py
Enter any value : chandra
chandra
<type 'str'>
$ python sample.py
Enter any value : 1234
1234
<type 'str'>
$ python sample.py
Enter any value : 1.235
1.235
<type 'str'>

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment