Convert All Elements in a List to Upper Case – Python

Here are 2 ways to convert all elements in a list to upper case:

(1) Using a List Comprehension:

my_list = ['aa', 'bb', 'cc', 'dd', 'ee']
upper_case_list = [i.upper() for i in my_list]

print(upper_case_list)

The result:

['AA', 'BB', 'CC', 'DD', 'EE']

(2) Using a For Loop:

my_list = ['aa', 'bb', 'cc', 'dd', 'ee']

upper_case_list = []

for i in my_list:
    upper_case_list.append(i.upper())

print(upper_case_list)

The result:

['AA', 'BB', 'CC', 'DD', 'EE']

Alternatively, you may use the following generator to convert all the elements in your list to upper case:

Enter List Name: Enter List Values: Enter New List Name:

For example:

Convert All Elements in a List to Upper Case - Python

You may check the following guide for the steps to convert all elements in a list to lower case.