Solve problem "Swap neighbours" online - Learn Python 3 - Snakify

Problem «Swap neighbours» (Medium)


Statement

Given a list of numbers, swap adjacent items in pairs (A[0] with A[1], A[2] with A[3], etc.). Print the resulting list. If a list has an odd number of elements, leave the last element in place.

In all the problems input the data using input() and print the result using print().



Saved solutions

Tests

Input Correct answer Result
1 2 3 4 5
2 1 4 3 5
4 5 3 4 2 3
5 4 4 3 3 2
9 4 5 2 3
4 9 2 5 3
6
6
7 8
8 7
1 2 3
2 1 3
90 45 3 43
45 90 43 3
40 64 -80 -98 -68 56 85 87 -68 -78
64 40 -98 -80 56 -68 87 85 -78 -68
-1 -11 -40 3 -47 -37 -18 -100 6 -29 14 -1 -89 -20 -36 7 5 78 -5 85
-11 -1 3 -40 -37 -47 -100 -18 -29 6 -1 14 -20 -89 7 -36 78 5 85 -5
-46 35 72 -79 38 -32 1 23 -84 -84 50 -46 -57 -44 72 33 91 -6 88 91 -12 -76 -78 95 63 45 54 13 58 -19 30 48 -98 37 97
35 -46 -79 72 -32 38 23 1 -84 -84 -46 50 -44 -57 33 72 -6 91 91 88 -76 -12 95 -78 45 63 13 54 -19 58 48 30 37 -98 97