Python String isdigit() Method

Last Updated:

Python String isdigit()

The isdigit() method checks whether all the characters of the string are digits or not.

Note: Exponents, like 2, are also considered to be a digit.

Example

Python Compiler
str1 = "python" str2 = "123" str3 = "\u0031" # unicode for 1 str4 = "\u00B2" # unicode for ² print(str1.isdigit()) # False print(str2.isdigit()) # True print(str3.isdigit()) # True print(str4.isdigit()) # True

Syntax

txt.isdigit()

Parameter Values

It does not take any parameter.

Return Value

ValueExplanation
True If the characters of the string contains only digits.
False If the characters of the string contains other than digits.

Share this Page

Meet the Author