Python Glossary Русский

all Python 3Strings (str)function

str.isupper

character checks

True if all cased characters are uppercase and there is at least one.

Syntax

s.isupper()

Only cased characters are examined: digits and punctuation are ignored, yet a string with no letters at all returns False, so '123' and the empty string are not uppercase. That is why isupper() is not the same as s == s.upper(): for '123' the comparison holds while the method returns False.

Examples

print('ABC'.isupper())   # → True
print('Abc'.isupper())   # → False
print('ABC!'.isupper())  # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy