Swap Nodes in Pairs

valuesArray
[1, 2, 3, 4]
1def swapPairs(head):
2  dummy = ListNode(0)
3  dummy.next = head
4  prev = dummy
5
6  while prev.next and prev.next.next:
7    first = prev.next
8    second = first.next
9
10    # Swap the pair
11    prev.next = second
12    first.next = second.next
13    second.next = first
14
15    # Move to next pair
16    prev = first
17
18  return dummy.next
0 / 12
1234