How to get user input in Python?
To get input from the user in Python program, Python provides two methods.
raw_input(): This 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.
input(): This 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.
This program 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.
See, in this program, user input is string type. We used type() method to check value type.
Program Example: Casting User input
See, in this program, we are converting user input into int type. This is called type casting, we will discuss it in detailed in type casting topic.