replacing particular elements in a list,mylist = [('XXX' if v == 'abc' else v) for v in mylist]