Use Python capitalize() method to capitalize every first letter of a word in the list. You have to also use for loop to iterate through the list.
Example How tocapitalize the first letter of every word in the list
Python simple code.
list1 = ["Hello", "how", "are", "you"] for i in range(len(list1)): list1[i] = list1[i].capitalize() print(list1)
You can also use the python string title method with the same process.
list1 = ["Hello", "how", "are", "you"] for i in range(len(list1)): list1[i] = list1[i].title() print(list1)
Output: [‘Hello’, ‘How’, ‘Are’, ‘You’]
Do comment if you have any doubts and suggestions on this python list topic.
Note: IDE: PyCharm 2021.3.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.