String Methods

str.isalnum()

Classify a nonempty string whose characters each satisfy at least one of the letter, decimal, digit or numeric tests. This accepts letters and numeric symbols from many scripts, not just ASCII. Spaces, underscores, punctuation and standalone combining marks fail. It does not validate identifiers or restrict confusable characters. Takes no arguments.

Formal Syntax & Structure

python syntaxpython
text.isalnum()

Return Value

bool

True when the stated classification holds; otherwise False.

Working Example

Example Snippetpython
for code in ("A12", "کد۴۲", "A_12", "", "½"):    print(repr(code), code.isalnum())
Python Reference