Method Name:
isalnum
Method Signature:
isalnum()
Method Overview:
- The isalnum() method of str class in Python, returns True if the string contains only alphabets and/or digits.
- isalnum() returns False if the string has at least one non-alphanumeric character or no alphanumeric character.
Example:
testString = "Year1969" status = testString.isalnum() print("Given string is Alphanumeric:{}".format(status))
numString = "123987" status = numString.isalnum() print("Given string is Alphanumeric:{}".format(status))
spString = "*% @#$" status = spString.isalnum() print("Given string is Alphanumeric:{}".format(status)) |
Output:
Given string is Alphanumeric:True Given string is Alphanumeric:True Given string is Alphanumeric:False |