How to take integer input in Python 3
![how to take integer input in python 3](https://pythonpoint.net/wp-content/uploads/2020/11/how-to-take-integer-input-in-python-3-1024x576.jpg)
The inbuilt function input() in Python 3.x returns a str(string) class object. Irrespective of the input data type, it always returns a string.
In order to take integer input, we need to type cast those inputs into integers by using Python built-in int() function.
x = input() print(type(x)) print() y = int(input()) print(type(y))
Output:
22 <class 'str'> 22 <class 'int'>
Subscribe
Login
Please login to comment
0 Discussion