Python String upper() Method Tutorial

The string is an important part of Python programming. A string may contain lowercase and upper case letters. If we need to make all lowercase letters uppercase there is the upper() method. Even there are alternative ways the easiest and fast way is using the upper() method of a string type.

upper() Method Syntax

The upper() method has the following syntax. The upper() method does not take any parameter and uppercase STRING is returned.

  • STRING is the string variable, object or literal which is converted into the uppercase.

upper() Method with String Variable

The upper method can be used for a string variable or object. The execution of the upper() method returns the uppercase of the provided string variable or object.

name = "ismail"

surname = "baydan"




The output will be like below. The surname is not uppercase because the returned uppercase value is not stored.


upper() Method with String Literal

The upper() method can be also used for the string literal even without creating a variable or object. The provided string literal is returned as uppercase.


The output is like below.


Reverse upper() Method (lower())

The uppercase letters can be returned into the lowercase by using the lower() method. This is called reversing the upper() method. The syntax is the same with the upper() method where the only difference is return value is lowercase.


The output will be like below.


upper() vs capitalize()

Python provides the capitalize() method in order to make every word’s first letter uppercase. The difference between upper() and capitalize() method is the upper() method converts all letters to uppercase but the capitalize() method only converts the first letter to uppercase.

name = "ismail"

print("capitalize method:",capitalize(name))

print("upper method:",upper(name))
capitalize method: Ismail
upper method: ISMAIL

Leave a Comment