Python Function Reference

str.upper

Convert all letters of the string to uppercase.

Python 3.13
str.upper()

Return value

A new string; the original is not changed.

Examples

Converting to uppercase

Python 3.13
print('hello'.upper())
HELLO

The string gets longer

Python 3.13
word = 'straße'
print(word.upper(), len(word), len(word.upper()))
STRASSE 6 7

Details

The length of the string can change: some letters have no single uppercase pair, for example the German ß becomes SS. Digits and punctuation do not change. For case-insensitive comparison, str.casefold is more reliable.

See also

Where to learn