In this Python list program, we will take a user input as a list and convert 3rd character of each word to the capital with the help of the below-given steps.
The character of each word to capital letter:
Steps to solve the program
- Take a list containing words as input.
- Use a for loop to iterate over words in the list.
- If the length of the word is greater than 3 then convert the 4th character of each word to capital using indexing and the upper() function.
- If not then add that word to the empty list.
- Add the new words to another list.
- Print the list to see the result.
#Input list
list1 = ["Hello", "student", "are", "learning",
"Python", "Its", "Python", "Language"]
list2 = []
for value in list1:
if len(value)>3:
list2.append(value[:3]+value[3].upper()
+value[4:])
else:
list2.append(value)
#Printing output
print(list2)
Output :
['HelLo', 'stuDent', 'are', 'leaRning', 'PytHon', 'Its', 'PytHon', 'LanGuage']
Related Articles
Python program to remove the 2nd character of each word from a given list.
Python program to get a length of each word and add it as a dictionary from the given list.
Python program to remove duplicate dictionaries from the given list.
Python program to decode a run-length encoded given list.
Python program to round every number in a given list of numbers and print the total sum of the list.
Python Program to get the Median of all the elements from the list.