Possible Duplicate:
iterate through pairs of items in python list
I have a list and i want to create another one which will encompasses sequent groups of item of the first one based one sliding-window parameter and the size of each group. i.e if the parameter:
a = ["a" ,"b" ,"c" ,"d" ,"e" ,"f"]
and sliding-window=1 and size =2 then i want b as:
b= [(a,b),(b,c),(c,d),(d,e),(e,f)]
the sliding window is for deciding the index of the next tuple.Each time the list would traversed by 1.I.e: If the sliding window was 2 then i would have: b= [(a,b),(c,d),(e,f)]
i am looking for a pythonic-way of achieving this.