How to Convert First Letter Capitalize in Python?
Nov 07, 2022
Hi Dev,
I will explain step by step tutorial how to convert first letter capitalize in python. We will use python list convert into capitalize title example. This article will give you simple example of convert list to title case python. This tutorial will give you simple example of python list convert to title case.
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.
so let's see following examples 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']
- 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?