I have a list of tuples which represent timeslots (start_epoch, end_epoch). What I'm trying to accomplish is the following:
If have this list:
[
(1398932511, 1398932991),
(1398933052, 1398933142),
(1400018571, 1400020941),
(1400020941, 1400024572),
(1400024572, 1400027541),
(1400027602, 1400028172),
(1400824012, 1400824162)
]
I want the tuples which are consecutive to be joined together in a new list. So the result would be this:
[
(1398932511, 1398932991),
(1398933052, 1398933142),
(1400018571, 1400027541),
(1400027602, 1400028172),
(1400824012, 1400824162)
]
I have been looking around (stackoverflow, Google) but I'm unable to find a proper solution to this. I can't figure out how to properly use itertools for python (I'm fairly new to Python :) ).