skull wrote: > According to Nick's article, I added three 'reversed' methods to your provided > test prog. and the result turned out method_reversed is faster than others except the 'three' case. > Following is my modified version: [snip] > def method_reversed_idx(lst): > idx = 0 > for i in reversed(lst): > if i == 2: > del lst[idx] > idx += 1
There appears to be a problem with this one: >>> def method_reversed_idx(lst): ... idx = 0 ... for i in reversed(lst): ... if i == 2: ... del lst[idx] ... idx += 1 ... >>> lst=[1,2,3];method_reversed_idx(lst);print lst [1, 3] >>> lst=[2,1,3];method_reversed_idx(lst);print lst [2, 1] >>> lst=[1,3,2];method_reversed_idx(lst);print lst [3] >>> -- http://mail.python.org/mailman/listinfo/python-list