[Tutor] Can you modify every nth item in a list with a single assignment?

Alan Gauld alan.gauld@blueyonder.co.uk
Fri Jun 13 03:01:02 2003


> I think one thing you might be able to do is use list comprehensions
(after
> v2.0, correct me if I'm wrong).

We tried this once before and came to the conclusion it couldn't be
done, if I recall correctly. The problem is you can't access the
current
index of the list from inside a comprehension(or a map(), filter()
etc)

I think an explicit loop is the only solution for this type of
operation in versions prior to 2.3.

Alan G.