transformation

str.upper

Returns a copy of the string with all cased characters converted to uppercase. Non-cased characters (digits, punctuation, whitespace) are unchanged.

str.upper()

Parameters

Parameter Purpose
self operates on the calling string; takes no arguments
returns new uppercased str (original is unchanged — str is immutable)

Examples

>>> 'Hello, World!'.upper()
'HELLO, WORLD!'

only cased letters change

>>> 'straße'.upper()
'STRASSE'

German ß expands to 'SS' (length can change)

>>> '123 abc'.upper()
'123 ABC'

digits untouched

>>> 'áéí'.upper()
'ÁÉÍ'

accented Unicode letters are handled

Gotcha

Result length can change (e.g. 'ß' becomes 'SS'), so upper() is not safe for case-insensitive comparison — use casefold().

Related methods

← All Python string methods · Python built-ins