In Python, you can use the str.lower()
and str.upper()
methods to change the case of all characters in a string to lowercase or uppercase, respectively. These methods have been part of the programming language for almost two decades. They are still widely used today.
Converting to lowercase using the lower() method
Example:
my_string = "Welcome to Sling Academy!"
lowercase_string = my_string.lower()
print(lowercase_string)
Output:
welcome to sling academy!
Converting to uppercase using the upper() method
Example:
my_string = "Some greate RPG games are Witcher 3, Elden Ring, Cyberpunk 2077, and God of War."
uppercase_string = my_string.upper()
print(uppercase_string)
Output:
SOME GREATE RPG GAMES ARE WITCHER 3, ELDEN RING, CYBERPUNK 2077, AND GOD OF WAR.