Python 3 reference · String Methods

Python String upper() Method

Return a copy of the string with all cased characters converted to upper case.

Python 3 Since 3.0

Syntax

str.upper()

Return value

A new string.

Examples

Basic useTry it yourself
print("hello world".upper())

Output

HELLO WORLD
Codes, and a special caseTry it yourself
code = "ab-12x"
print(code.upper(), "straße".upper())

Output

AB-12X STRASSE

Version history

VersionChange
Python 3.0Added