the code:
>>> mylist = ['abc','def','ghi'] >>> mylist ['abc', 'def', 'ghi'] >>> for i,v in enumerate(mylist): ... if v=='abc': ... mylist[i] = 'XXX' ... >>> mylist ['XXX', 'def', 'ghi'] >>>
Here I am trying to replace all occurrences of 'abc' with 'XXX' . Is there a shorter way to do this?
bdhar
source share