Python isnumeric is one of the Python String Methods used to check whether the characters are numeric characters or not. And if they are numeric values, string isnumeric returns True otherwise, False.
In this section, we discuss how to write isnumeric in Python Programming with example. The syntax of the string isnumeric function is
String_Value.isnumeric()
- String_Value: Please select a valid String literal.
Python isnumeric example
The following set of examples help you understand the isnumeric function.
Please refer to the Python String and Python String Methods articles to understand the strings in Python.
# Python string isnumeric Method Example Str1 = '123456789'; print('First Output of a isnumeric() method is = ', Str1.isnumeric()) Str2 = ' '; print('Output of a isnumeric() method For Empty Space is = ', Str2.isnumeric()) # Performing isnumeric() function On Unicode Values # \u00BD is the Unicode Value of '1/2' Str3 = '\u00BD'.isnumeric() print('Second Output of a isnumeric() method is = ', Str3) # Performing isnumeric() on both Numeric Values and Alphabets Str4 = '123a'.isnumeric() print('Third Output of a isnumeric() method is = ', Str4) # Performing isnumeric() on Float values Str5 = '1234.67'.isnumeric() print('Fourth Output of a isnumeric() method is = ', Str5) # Performing isnumeric() on Negative Values Str6 = '-1234'.isnumeric() print('Fifth Output of a isnumeric() method is = ', Str6) # Performing isnumeric() on Numeric Values and Special Characters Str7 = '[email protected]'.isnumeric() print('Sixth Output of a isnumeric() method is = ', Str7)
OUTPUT