Menu Close

Python String isdecimal() Method:

Python string isdecimal() method

In this article, we are going to learn the Python string isdecimal() method. String isdecimal function is a built-in function that returns True if the string contains decimal characters otherwise return False.

In the previous tutorial, we have seen the Python string isalnum() method to check whether a String contains alphanumeric characters or not.

Python String isdecimal() Method:

The Python string isdecimal() method is a built-in string method that is used to check whether a string contain decimal characters or not. If the string contain decimal characters it returns True otherwise it returns False.

Syntax:

The syntax of Python string isdecimal method is:-

string.isdecimal()

Parameter:

The String isdecimal() method does not support any parameter.

Return Type:

String isdecimal function returns Boolean value: True or False

Python string isdecimal() Method Example:

Here we will take various example to understand string isdecimal function.

Example 1:

str = "Programming"
str2 = str.isdecimal()
print(str2)

In above example Output will be False because str does not contain decimal characters.

Example 2:

str = "123423"
str2 = str.isdecimal()
print(str2)

In above example Output will be True because str contains decimal characters.

Example 3:

str = "1242.23"
str2 = str.isdecimal()
print(str2)

In above example Output will be False because str does not contain decimal characters.

Conclusion:

In this tutorial, you have learned the Python string isdecimal() method to check whether a string contains decimal characters or not. If the string contains a decimal value, Then it returns True otherwise it returns False.

I hope this tutorial will have helped you. If you like this article, please share it with your friends who want to learn Python programming.

For More Information:- Click Here

Python String isalnum() Method
Python String isdigit() Method

Related Posts