With a comprehension? Well...
>>> seq = '012345' >>> swapped_pairs = zip(seq[1::2], seq[::2]) >>> ''.join(item for pair in swapped_pairs for item in pair) '103254'
2.1m questions
2.1m answers
60 comments
57.0k users