Using Python, what’s the most efficient way to switch the positions of every other element in a list?
For example, I’m trying to get a sequential list of the alphabet with each letter after A switched, like so:
import string
alphabet = string.ascii_uppercase
# ABCDEFGHIJKLMNOPQRSTUVWXYZ
switched_alphabet = do_something_magic(alphabet)
# ACBEDGF...
# position 1, 3, 2, 5, 4, 7, 6...
1 Answer