How to Convert List to Uppercase in Python?
Hi,
This post will give you example of python convert list values to uppercase. I would like to show you convert list to uppercase python. let’s discuss about convert list elements to uppercase python. you will learn convert list data to uppercase python.
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.
You can use these examples with python3 (Python 3) version.
let's see below a simple example 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']
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Convert List to Lowercase in Python?
- How to Convert List into String in Python?
- Python Split String into List of Characters Example
- How to Convert String into List in Python?
- How to Remove Duplicate Values from List in Python?
- How to Get Unique Elements from List in Python?
- How to Remove null Values from the List in Python?
- Python Remove Empty String from List Example
- Python Get Second Last Element of List Example
- How to Get the Last Element of a List in Python?
- How to Get First Element of List in Python?
- How to Remove Last Element from List in Python?
- How to Remove First Element from List in Python?