Python - String Method - isalnum() Tutorial
The isalnum() method returns True if all characters in the string are alphanumeric(either alphabets or numbers). otherwise, it returns False.
Syntax-
String.isalnum()
Example-
#contain white space also
str1 = "Hello Sam425"
print(str1.isalnum())
#contain both alphabet & numeric
str2 = "HelloSam425"
print(str2.isalnum())
Output-
False
True