Python int() Function

Python int() is a built-in method that returns an integer object from any number or string. The method accepts value and base as arguments and returns an integer value.


int(value, base)


value parameter is a number or a string that can be converted into an integer number.

A base parameter is a number representing the number format. The default value is 10.


data = "1921"



Python Int Function Tutorial

The int() function returns,

  1. The integer object from a given number or string treats the default base as 10.
  2. If there are no parameters, then it returns a 0.
  3. If the base has been given, it treats the string in the given base (0, 2, 8, 10, 16).

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.