Python 3 – String isalnum() Method
Python 3 – String isalnum() Method
Description
isalnum() method checks if a string consists of letters and numbers.
Syntax
Below is the syntax of the isalnum() method −
str.isalnum()
Parameters
None
Return Value
Returns true if all characters in the string are letters or numbers and there is at least one character; otherwise, returns false.
Example
The following example demonstrates the use of the isalnum() method.
#!/usr/bin/python3
str = "this2016" #This string has no spaces
print (str.isalnum())
str = "this is the string example....wow!!!"
print (str.isalnum())
Result
When running the above program, the following result is produced: −
True
False