[Tutor] Can you modify every nth item in a list with a single assignment?
Gus Tabares
gus.tabares@verizon.net
Thu Jun 12 20:33:01 2003
Bob Gailer wrote:
>> What we need here is a new language feature that lets us provide a
>> sequence of index values to a list. Something like:
>>
>> MyList[(1,4,9,23)] = MyList[(1,4,9,23)] + 43
> This can be done easily enough without adding a new feature, it just
> takes two lines instead of one
Or another healthy alternative, on one line:
map((lambda x: x + 43), [1, 4, 9, 23])
HTH,
Gus
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor