In this post, We will see how to take integer input in Python. As we know that Python built-in input() function always returns a str(string) class object. So for taking integer input we have to type cast those inputs into integers by using Python built-in int() function.
Let’s see the examples:
100 <class 'str'> <class 'int'>
10 <class 'str'> 20 <class 'int'>
10 20 30 40 50 60 70 array: ['10', '20', '30', '40', '50', '60', '70'] 10 20 30 40 50 60 70 array: [10, 20, 30, 40, 50, 60, 70]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Take Matrix input from user in Python
- Take input from stdin in Python
- Python | Pandas dataframe.take()
- Python | Pandas TimedeltaIndex.take()
- Python | Pandas Series.take()
- Python | Numpy matrix.take()
- How to take screenshots using python?
- How to take screenshot using Selenium in Python ?
- Create a Python Script Notifying to take a break
- numpy.take() in Python
- What is the maximum possible value of an integer in Python ?
- Program to print all distinct elements of a given integer array in Python | Ordered Dictionary
- Python Map | Length of the Longest Consecutive 1's in Binary Representation of a given integer
- Python | Binary list to integer
- Python | Integer count in Mixed List
- Python | Convert list of string into sorted list of integer
- Python | Split a list having single integer
- Python | Ways to convert Boolean values to integer
- Python | sympy.Integer() method
- Python | Convert Tuple to integer
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.