88 of 151 menu

The upper method

The upper method returns a string in which all characters of the string are in uppercase. We do not specify anything in the method parameter.

Syntax

string.upper()

Example

Let's apply the upper method to the following line:

txt = 'AbcDef' print(txt.upper())

Result of code execution:

'ABCDEF'

Example

Now let's apply the upper method to a string consisting of two words:

txt = 'AbWith DeA' print(txt.upper())

Result of code execution:

'ABWith DEA'

See also

  • method capitalize,
    which changes the first character of a string to uppercase
  • method isupper,
    which checks all characters in a string for uppercase
  • method title,
    which changes the first character of each word to uppercase
  • method islower,
    which checks the characters of a string for lowercase
  • method lower,
    which returns all lowercase characters
  • method casefold,
    which returns all unicode characters in lowercase
  • method isupper,
    which checks all characters in a string for uppercase
  • method swapcase,
    which changes the case of characters to the opposite
byenru