[Tutor] for: how to skip items

Dave Angel davea at davea.name
Mon Feb 17 19:54:59 CET 2014


 Gabriele Brambilla <gb.gabrielebrambilla at gmail.com> Wrote in message: 

> in the end I'm using something like this and it works:

> zipPARApha = zip(Pampli, Pgamma, Pecut, Pb, g)
> for n, (a1,b1,c1,d1,pha) in enumerate(zipPARApha):

> where the arguments of zip are lists of the same size.

Simpler would be:

for a1,b1,c1,d1,pha in zipPARApha[9::10]:

or if the list is huge,  the islice equivalent. 

The [9::10] syntax says you want to slice out elements 9, 19, etc.


-- 
DaveA



More information about the Tutor mailing list