Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python isalnum() method

Python isalnum() method

Python Strings Python Strings


Description

The Python isalnum() method checks whether a string consists of letters and digits.

Syntax

Syntax of the isalnum() method:



str.isalnum()

Parameters

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

print

str

.

isalnum

(

)

;

str

=

"

this is string example....wow!!!

"

;

print

str

.

isalnum

(

)

;

The output of the above example is:



True

False


Python Strings Python Strings