Python int() Function

Example

Convert the number 3.5 to an integer:

x = int(3.14)

Run Example

Definition and Usage

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

Syntax

int(value, base)

Parameter Value

Parameter Description
value A number or string that can be converted to an integer.
base Represents a number in numeric format. Default value: 10.

More Examples

Example

Convert String to Integer:

x = int("15")

Run Example