Menu Close

Python String isdigit() Method

Python string isdigit() method

In this article, you will learn about the Python string isdigit() method. string isdigit function in python is a string method that is used to check whether a string contains digits or not.
In the previous tutorial, we have seen a string isdecimal() method to check a string contains a decimal or not.

Python string isdigit() method:

String isdigit function is a built-in string function that is used to check whether a string contains digits or not. If the string contains digits, it returns True otherwise it returns False.

Syntax:

Syntax of string isdigit function in python is:

string.isdigit()

Parameter:

The Python string isdigit method not support any parameter.

Return Type:

The string isdigit function in python return True or False.

Python string isdigit Example:

Here we will take some example to understand string isdigit function.

Example 1:

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

In above example output will be True because str contains digits.

Example 2:

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

In above example output will be False because str contains alphabets.

Example 3:

str = "[email protected]#!"
str2 = str.isdigit()
print(str2)

In the above example output will be False because str contains digits as well as special characters.

Conclusion:

In this tutorial, you have learned the python string isdigit() method to check whether a string contains digits or not. if the string contains digits, It will return True otherwise False.

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

String Methods

For More Information:- Click Here

Previous Article
Next Article

Was this post helpful?

Related Posts

Leave a Reply