Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

str.isalnum

Tests whether every character is alphabetic or numeric and at least one character exists.

Version: Python 3.14; repository image, production runtime not attested

Syntax

s.isalnum()

Tests whether every character is alphabetic or numeric and at least one character exists.

Unicode letters and numbers participate, while the empty string fails.

The letter A and the Arabic-Indic decimal digit both qualify, so the mixed string passes. Punctuation and whitespace fail, and the empty string is explicitly false.

assert "½".isalnum() and not "a_b".isalnum()

Examples

print("A٣".isalnum())
print("".isalnum())

Result

True
False

The letter A and the Arabic-Indic decimal digit both qualify, so the mixed string passes. Punctuation and whitespace fail, and the empty string is explicitly false.

Sources