int()
Built-in FunctionPython 2.0+Beginner
Converts a value to an integer
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
print(int("42")) print(int(3.14)) print(int(True)) print(int("ff", 16))
int() is a built-in function that converts a value to an integer.
Try in PlaygroundTags
builtinfunctioncoredatatypenumericconversion
Related Items
float()
Built-in Function
Converts a value to a floating-point number
str()
Built-in Function
Converts a value to a string
bool()
Built-in Function
Converts a value to a Boolean (True or False)
bin()
Built-in Function
Converts an integer to a binary string prefixed with '0b'
hex()
Built-in Function
Converts an integer to a hexadecimal string prefixed with '0x'
oct()
Built-in Function
Converts an integer to an octal string prefixed with '0o'