Web development and Tech news Blog site. WEBISFREE.com

HOME > python

How to convert lower case to upper case in Python

Last Modified : 04 Mar, 2023 / Created : 04 Mar, 2023
View Count

Let's learn how to change the case (upper or lower case) of letters in Python, which is simple but essential. How can we change the case of letters in Python?

[ Note ]
If you need to change the case in an HTML template, please refer to the link below for how to change the case in Jinja2.

# How to change the uppercase and lowercase letters in Python.

There are various ways to change the case of Python. Among them, the built-in functions used for strings are representative. Let's take a look at the two functions, upper() and lower(), right below.

.upper() // Convered to uppercase letters

.lower() // Converted to lowercase letters

"Upper() and lower() are useful functions that can respectively change text to uppercase and lowercase letters. Let's take a simple example. Please see the following example."

! Convert to uppercase letters, upper()

"I am trying to change the variable 'test' which is written in lowercase to uppercase. I will run the code as follows."
test = 'abc'

// Result

You can see that the value of variable "test" has been changed from lowercase "abc" to uppercase "ABC". This can be easily done. The following is the opposite case.

! Change uppercase to lowercase, lower()

On the other hand, I want to change uppercase letters to lowercase. This time, I will use lower().
test2 = 'ABC'

// Result

The expected result has been achieved. The uppercase letters have been changed to lowercase letters "abc".

So far, we have briefly looked at the method of changing uppercase and lowercase letters in Python.
Perhaps you're looking for the following text as well?


    [Python] How to use cookies in Flask, cookie


    Python text character replacement method, substitute method, replace()