Need help porting Perl function
socyl at 987jk.com.invalid
Sun Jun 8 18:52:54 CEST 2008
In <g2h2kb$43g$1 at reader2.panix.com> kj <socyl at 987jk.com.invalid> writes:
>In <7248c81b-0ff9-45f5-acb5-63a8b2d41817 at f24g2000prh.googlegroups.com> John Machin <sjmachin at lexicon.net> 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
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.
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
More information about the Python-list