Upper() Method Of Str Class

Method Name:

upper

Method Signature:

upper()

Return Value:

A string of all uppercase characters. 

Method Overview:

  • For a given string of characters the method uppercase() returns a string whose characters are all in uppercase.

Example:

# Example Python program that converts strings 
# of various cases to uppercase

# Lowercase to uppercase
txt = "warning";
print("Lowercase:%s"%txt);
print("Uppercase:%s"%txt.upper());

# Titlecase to uppercase
txt = "New York City";
print("Titlecase:%s"%txt);
print("Uppercase:%s"%txt.upper());

# Mixed to uppercase
txt = "Lakes of the world";
print("Mixed case:%s"%txt);
print("Uppercase:%s"%txt.upper());

Output:

Lowercase:warning

Uppercase:WARNING

Titlecase:New York City

Uppercase:NEW YORK CITY

Mixed case:Lakes of the world

Uppercase:LAKES OF THE WORLD


Copyright 2020 © pythontic.com