Python String upper() Method

The upper() method returns a string in the upper case. Symbols and numbers remain unaffected.

The main difference between the capitalize() and the upper() method is that the capitalize() method will capitalize only the first character of the string, whereas the upper() will convert all characters in the upper case.

Syntax:

str.upper()

Parameters:

None.

Return Value:

An upper case string

The following example demonstrates converting string to uppercase.

Example: Capitalize a word
>>> mystr = 'Hello World' 
>>> mystr.upper() 
'HELLO WORLD'
>>> 'heLLo wORld'.upper() 
'HELLO WORLD'

The following example converts a string with a number and symbol to uppercase.

Example: Capitalize a word
>>> '1# Harbor Side'.upper()
'1# HARBOR SIDE'
>>> '123456'.upper()
'123456'
>>> '123abc'.upper()
'123ABC'
Want to check how much you know Python?