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?<
a = [1,2,3,4,5,1,2,3,4,5,1,12] for i in range (len(a)): if a[i]==2: a[i]=123
You can use a for and or while loop; however if u know the builtin Enumerate function, then it is recommended to use Enumerate.1