Python int() Function

❮ Built-in Functions


Example

Convert the number 3.5 into an integer:

x = int(3.5)
Try it Yourself »

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")
Try it Yourself »

❮ Built-in Functions

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.