In <[EMAIL PROTECTED]> kj <[EMAIL PROTECTED]> writes: >In <[EMAIL PROTECTED]> John Machin <[EMAIL PROTECTED]> writes:
>>It's nothing to do with list comprehensions, which are syntactical >>sugar for traditional loops. You could rewrite your list comprehension >>in the traditional manner... >>and it would still fail for the same reason: mutating the list over >>which you are iterating. >I normally deal with this problem by iterating backwards over the >indices. Here's how I coded the function (in "Python-greenhorn >style"): ***BLUSH*** Somehow I missed that John Machin had posted almost the exact same implementation that I posted in my reply to him. Reading too fast. Reading too fast. Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded. -- http://mail.python.org/mailman/listinfo/python-list