Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
list extend solution in Clear category for Swap Nodes by Sioul
def swap_nodes(a):
new_list = []
for i in range(len(a)//2):
new_list.extend((a[2*i+1], a[2*i]))
if len(a) % 2:
new_list.append(a[-1])
return new_list
Dec. 16, 2019
Comments: