Python raw_input read input from keyboard

By |2019-04-13T23:03:45+05:30June 2nd, 2017|Python|

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 :

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

If we use raw_input() function, whatever the type of data we given as an input, it will internally convert 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
Enter any value : chandra
<type 'str'>
$ python
Enter any value : 1234
<type 'str'>
$ python
Enter any value : 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