List slicing
For shorter lists:
>>> alphanums = ['a', 1, 'b', 2, 'c', 3, 'd', 4] >>> alphas = alphanums[:-1:2] >>> nums = alphanums[1::2] >>> alphas ['a', 'b', 'c', 'd'] >>> nums [1, 2, 3, 4]
For longer sequences, use iterators:
import itertools >>> [ i for i in itertools.islice(['a', 1, 'b', 2, 'c', 3], 1, None, 2) ] [1, 2, 3]
Where 1, None, 2 correspond to the start, end and steps to take.