Convert Strings into Integers in Python

Convert Strings into Integers in Python

Table of Contents

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

 

Leave a Comment

Your email address will not be published. Required fields are marked *

No data found.