I want to swap each pair of characters in a string. \'2143\' becomes \'1234\', \'badcfe\' becomes \'abcdef\'.
\'2143\'
\'1234\'
\'badcfe\'
\'abcdef\'
How
One more way:
>>> s='123456' >>> ''.join([''.join(el) for el in zip(s[1::2], s[0::2])]) '214365'