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'
548k questions
547k answers
4 comments
86.3k users