THE WORLD'S LARGEST WEB DEVELOPER SITE

Python int() Function

❮ Built-in Functions


Example

Convert the number 3.5 into an integer:

x = int(3.5)
Run example »

Definition and Usage

The int() function converts the specified value into an integer number.


Syntax

int(value, base)

Parameter Values

Parameter Description
value A number or a string that can be converted into an integer number
base A number representing the number format. Default value: 10

More Examples

Example

Convert a string into an integer:

x = int("12")
Run example »

❮ Built-in Functions