01-Nov-2022
.
Admin
Hi Dev,
In this example, I will show you Convert List to Uppercase in Python Example. We will look at example of How to Convert List Elements to Uppercase in Python. I would like to show you Convert List to Uppercase Python. if you want to see example of How to Convert List to Uppercase in Python then you are a right place.
There are many ways to convert list elements to uppercase in python. i will give you two examples using for loop with upper() to convert list data to uppercase. so let's see the below examples.
so let's see following examples with output:
Example 1:
main.py
myList = ['One', 'two', 'Three']
# Convert List Value into uppercase
for i in range(len(myList)):
myList[i] = myList[i].upper()
print(myList)
Output:
['ONE', 'TWO', 'THREE']
Example 2:
main.py
myList = ['One', 'two', 'Three']
# Convert List Value into uppercase
newList = [x.upper() for x in myList]
print(newList)
Output:
['ONE', 'TWO', 'THREE']
#Python