Python Tutorial Python Advanced Python Resources Python Libraries
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

Python - String isdecimal() Method



The Python String isdecimal() method is used to check whether all characters of the string are decimal or not. It returns true when all characters of the string are decimal, else returns false. Decimal characters belongs to numbers 0 - 9.

Syntax

string.isdecimal()

Return Value

Returns True if all characters of the specified string are decimal, else returns False.

Example:

In the example below, isdecimal() method is used to check whether all characters of the string are decimal or not.

MyString = "12345"
print(MyString.isdecimal())

The output of the above code will be:

True 

Example:

In the example below, isdecimal() method is used to check whether all characters of the unicode string object are decimal or not.

MyString = "\u0035"        #unicode for 5
print(MyString.isdecimal())

The above code will give the following output:

True  





❮ Python String Methods

5