Python isalnum() method
Description
The Python isalnum() method checks whether a string consists of letters and digits.
Syntax
Syntax of the isalnum() method:
str.isalnum()
Parameters
- none.
Return Value
Returns True if 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 characters
str
.
isalnum
(
)
;
str
=
"
this is string example....wow!!!
"
;
str
.
isalnum
(
)
;
The output of the above example is:
True
False
Python Strings