Python isalnum() Method
Description
The isalnum() method checks whether the string consists of letters and digits.
Syntax
Syntax of the isalnum() method:
str.isalnum()
Parameters
- None.
Return Value
Returns True if the string has at least one character and all characters are letters or digits; otherwise, returns False.
Example
The following example demonstrates the isalnum() method:
Example (Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
str = "this2009"; # No spaces in the string
print str.isalnum();
str = "this is string example....wow!!!";
print str.isalnum();
The output of the above example is:
True False
Other Extensions
Python Strings