Convert all Elements in a Python List to Upper Case

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']

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

Leave a Comment