The isalnum Method in Python: Checking a String for Letters and Numbers
Returns True or False, indicating whether the string contains only numbers and/or letters.
isalnum()
Returns True if the string has at least one character and all characters are numbers and/or letters; otherwise, returns False.
''.isalnum() # False
' '.isalnum() # False
'!@#'.isalnum() # False
'abc'.isalnum() # True
'123'.isalnum() # True
'abc123'.isalnum() # True