93. Problem to replace Java with Python from the given list.

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
  1. Take a list containing words as input.
  2. Use a for loop with the range function to iterate over words in the list.
  3. If a word is equal to Java replace it with Python.
  4. 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

Create a dictionary from a sublist in given list

Convert 3rd character of each word to capital

Leave a Comment