Swap Nodes Swap Nodes
English RU
The mission is in Reviewing Mode. You can't see the solutions Leader Board, but you can see other user solutions through the Random Review after you solve the mission.

Your task is to swap elements of the list (Iterable) pairwise. If you are given a list of 4 elements, then your function should return the same list, only in it the first and second elements are interchanged, as well as the third and fourth.

If there isn’t a paired amount of elements, then leave the last unpaired element in its place. An empty list should remain empty.

Input: Iterable.

Output: Iterable.


swap_nodes([1, 2, 3, 4]) == [2, 1, 4, 3]
swap_nodes([5, 5, 5, 5]) == [5, 5, 5, 5]