Menu Close

Python String isnumeric() Method

python string isnumeric

In this article, you will learn about the Python string isnumeric() method. string isnumeric function in Python is used to check whether a string contains numeric characters or not.

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

Python string isnumeric() method

isnumeric function in python is a string function that returns True if all the characters in the string are numeric ( 0- 9 ) otherwise return False.

Syntax

Syntax of Python string isnumeric method is:-

string.isnumeric()

Parameter

String isnumeric() method does not support any parameter.

Return Type

The string isnumeric() method return only Boolean value: True or False.

Let’s see an example for using python isnumeric() string method.

Python string isnumeric Example

Here we will take some examples to understand isnumeric function in python.

Example 1:

str = "12321"
str2 = str.isnumeric()
print(str2)

Output will be:- True

Example 2:

str = "PROGRAMMING1212"
str2 = str.isnumeric()
print(str2)

Output will be:- False

Example 3:

str = "12-21"
str2 = str.isnumeric()
print(str2)

Output will be:- False

Concluion:

In this tutorial, you have learned the Python string isnumeric() method check whether the string contains all the numeric characters or not. if the string contains all the numeric characters, it will return True otherwise return False.

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

For More Information:- Click Here

Previous Article
Next Article

Related Posts

Leave a Reply