Advertisement



< Prev
Next >



Python - String isnumeric() Method



The isnumeric() string method returns True if all the characters in a string are numerics, otherwise it returns False.

Note : None of the string methods change the original string and only return a new string which reflects the change performed by the string method, hence the returned string must be stored or used(if needed to reflect the result), otherwise it is lost.



Signature of isnumeric()


The isnumeric() method has no parameters, so we don't have to worry about passing it some value.

# Signature of isnumeric() method 
isnumeric()





Let us see a few more examples of calling the isnumeric() method on all different forms of strings.

# Python - Method isnumeric() Example



# Calling isnumeric() method on a string of digits with a comma
print('123,456'.isnumeric())


# Calling isnumeric() method on a string repesenting a specific currency value
print('5.43$'.isnumeric())



# Calling isnumeric() method on a string representing a floating value
print('12.99'.isnumeric())



# Calling isnumeric() method on a string of all digits except a !
print('999!'.isnumeric())


# Calling isnumeric() method of all binary digits
print('01011'.isnumeric())


Output is :


False
False
False
False
True


Program Analysis







Please share this article -





< Prev
Next >
< String rstrip() Method
String isdigit() Method >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement

Notifications



Please check our latest addition

PYTHON and DJANGO


Advertisement