Convert List to Uppercase in Python Example
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']
- Get Last 2 Digits of Number in Python Tutorial Example
- How to Sum of First and Last Digit of Number in Python?
- How to Get First and Last Digit of Number in Python?
- Get the Last Digit of Number in Python Tutorial Example
- Get the First Digit of Number in Python Tutorial Example
- How to Remove All Decimals from Number in Python?
- How to Convert String to Float with 2 Decimal Places in Python?
- How to Format Number to 2 Decimal Places in Python?