![]() |
VOOZH | about |
The isalnum() method is a string function in Python that checks if all characters in the given string are alphanumeric. If every character is either a letter or a number, isalnum() returns True. Otherwise, it returns False.
For Example:
True
Explanation: In this example, s contains only letters and numbers, so isalnum() returns True.
s.isalnum()
Parameters:
Return Type:
An empty string will return False since there are no alphanumeric characters.
False
The method will also return True for a string with only numeric characters.
True
Similarly, a string containing only letters will return True.
True
If the string contains a space and an exclamation mark, so isalnum() returns False.
False
Explanation: in this code, isalnum() returns False because the string s contains space " " and exclamation mark (!) which are neither numbers nor alphabets.