Python int() class
The int() class in Python returns an integer object constructed from a number or string x.
Syntax
1 2 3 |
class int(x, base=10) |
Parameter
x: This parameter represents a number or a string that can be converted into an integer number
base: This parameter represents a number representing the number format. Its default value is 10.
Return
This class return an integer object constructed from a number or string x, or return 0 if no arguments are given.
Example 1
1 2 3 4 5 6 7 8 |
# Python program explaining # the int() class #converting string to int value str= "987" x= int(str) print(x) |
Output
1 2 3 |
987 |