How to get user input in Python?
To get input from the user in Python program, Python provides two methods.
Python raw_input() Method
The raw_input() method is used to get user input but supported in the older versions of Python. We can use it with Python2.x version series. It is not supported in Python3 and later versions.
Python input() Method
The input() method is used to get user input but supported in the Python3 and latest versions of Python. We can use it with Python3.x version series. It is not supported in Python2 and earlier versions.
How To Take User Input in Python 3
This Code example is tested and executed using Atom IDE with Python 3.8 version.
Python input() method returns user input in string type. So if you want different type, use type casting.
How to check user input type in Python?
See, in this code example, user input is a string type. We used type() method to check value type in Python.
Casting User input in Python3
See, in this code example, we are converting user input into int type by using int() method. This is called type casting, we will discuss it in detailed in type casting topic.