Python String isnumeric() Method Tutorial

In this section, we will learn what String isnumeric() method is and how to use it in Python.

What is String isnumeric() Method in Python?

The Python string isnumeric() method is used to see if a string value contains only numbers (0-9) or not.

Python String isnumeric() Method Syntax:

string.isnumeric()

String isnumeric() Method Parameter

The method does not take an argument.

String isnumeric() Method Return Value

The return value of this method is of type boolean.

The value True means the target string only contains numbers.

But the value False means there’s at least one non-numeric character in the string.

Non-numeric characters include: !@#$%^&*()_+-= (a-z)(white-space)

Example: using python string isnumeric() method

s1= "THIS IS A SENTENCE"

s2 = "1234567"

s3 = " 122"

print(s1.isnumeric())

print(s2.isnumeric())

print(s3.isnumeric())

Output:

False

True

False
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies