In this Python lost program, we will take a user input as a list and replace Java with Python from the given list with the help of the below-given steps.
Replace Java with Python in a list:
Steps to solve the program
- Take a list containing words as input.
- Use a for loop with the range function to iterate over words in the list.
- If a word is equal to Java replace it with Python.
- Print the list after replacing it with the above words to see the output.
#Input list
list1 = ["Hello", "student", "are", "learning", "Python", "Its", "Python", "Language"]
for i in range(len(list1)):
if list1[i] == "Python":
list1[i] = "Java"
#Printing output
print(list1)
Output :
['Hello', 'student', 'are', 'learning', 'Python',
'Its', 'Python', 'Language']
Related Articles
Python program to convert the 3rd character of each word to a capital case from the given list.
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.