I have to search through a list and replace all occurrences of one element with another. So far my attempts in code are getting me nowhere, what is the best way to do this?<
This can be easily done by using enumerate function
code-
lst=[1,2,3,4,1,6,7,9,10,1,2] for index,item in enumerate(lst): if item==1: lst[index]=10 #Replaces the item '1' in list with '10' print(lst)