Raymond Hettinger wrote: > > for i,v in enumerate(L): > > if v == X: > > L[i] = Y > > Here's an alternate solution using a replacement dictionary: > > M = {X:Y} > for i, v in enumerate(L): > L[i] = M.get(v, v) but that's 2-3 times slower than the OP's corrected code for his use case, so I'm not sure it qualifies as more "efficient"... </F>