How to Use int() Function in PythonPython Basics


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

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

print("int(1):  ", int(1))
print("int('11'):  ", int('11'))
print("int('2'):  ", int('2'))

Output:

int(1):   1
int('11'):   11
int('2'):   2

Syntax

int(x)

Parameters

x — A string or number.

Return Value

It returns an integer number.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us