Convert Strings into Integers in Python

Convert Strings into Integers in Python

Just like the str() built-in, Python also offers a handy built-in which takes a String object as an argument and returns the corresponding integer object.

Example

# Here age is a string object
age = "21"
print(age)
# Converting string to integer
int_age = int(age)
print(int_age)

Output

21
21