Python Glossary Русский

all Python 3Strings (str)function

str.isalpha

character checks

True if the string is non-empty and all characters are letters.

Syntax

s.isalpha()

Letter means any Unicode letter, so Cyrillic, umlauts and CJK all pass, while a space, hyphen or apostrophe does not — 'Anna Maria' and 'Jean-Luc' come back False even though they are perfectly good names. The empty string is False as well, so a separate emptiness check is redundant. Superscripts like '²' count as numeric rather than alpha.

Examples

print('abc'.isalpha())    # → True
print('Привет'.isalpha())  # → True
print('abc1'.isalpha())   # → False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy