Wednesday, August 7, 2019

Python Program | Convert str to int in Python

int() is a built-in function used to convert string to integer in python. int() built-in function can be used to convert string object into integer in python.


int(value, base)

value = number or string to be converted into integer object.
base = base of the number. for eg - 10.


int() function converts string, integer and floats into integer.

Let's look at an example:

#integer value
print("int(678) is:", int(678))
#float value
print("int(678.23) is:", int(678.23))
#string value
print("int('678') is:", int('678'))


int(678) is: 678
int(678.23) is: 678
int('678') is: 678

Related Posts:

If You Enjoyed This, Take 5 Seconds To Share It