How can i get this
nums = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8)]
to this? The second item of each tuple is the first item of the next tuple.
[0, 1, 2, 3, 4, 5, 6, 7, 8]
I did:
>>> zip(*nums)[0]
(0, 1, 2, 3, 4, 5, 6, 7)
But it gives me everything except the last element and then i had to use some bad code to get it to the correct result so i was looking for an elegant solution.
Not sure what your general case is, but
For your example
also works, can you describe what you are trying to do rather than just giving one simple case?