Possible Duplicate:
pairwise traversal of a list or tuple
I have this list: [(0, 'set'), (1, 'of'), (4, 'coloured'),(5, 'eels')]
I would like to efficiently iterate and achieve item+1[0] - item[0]
as in 1 - 0, 4 - 1, 5 - 4
I currently have:
search_list = [(0, 'set'), (1, 'of'), (4, 'coloured')]
[search_list[i+1][0]-search_list[i][0] for i in range(0,len(search_list)-1)]
But my code is not as efficient as I would like. Can map and lambda achieve the outcome?
I would like to avoid importing modules (but, of course, will if lambda and map cannot achieve this)