How to Convert List to Capitalize First Letter in Python?
Hey,
Are you looking for an example of python list convert to capitalize first letter. I would like to show you capitalize the first letter of each word. you'll learn python list convert to title case. you will learn convert list to title case python. Let's see below example python list convert into capitalize title example.
There are many ways to convert list elements to capitalize first letter in python. i will give you two examples using for loop with title() to convert list data to capitalize first letter. 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 capitalize for i in range(len(myList)): myList[i] = myList[i].title() print(myList)
Output:
['One', 'Two', 'Three']
Example 2:
main.py
myList = ['one', 'two', 'three'] # Convert List Value into capitalize newList = [x.title() for x in myList] print(newList)
Output:
['One', 'Two', 'Three']
I hope it can help you...