(self, head)
return dummy.next
:type head: ListNode
        :rtype: ListNode
:type head: ListNode
        :rtype: ListNode
: type head : ListNode : rtype : ListNode
def swapPairs(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        dummy = h = ListNode(0)
        step = 1
        tmp = None
        while head:
            if step % 2:
                tmp = ListNode(head.val)
            else:
                h.next = ListNode(head.val)
                h.next.next = tmp
                h = h.next.next
                tmp = None
            head = head.next
            step += 1
        if tmp:
            h.next = tmp
        return dummy.next
def swapPairs ( self , head ) : dummy = h = ListNode ( 0 ) step = 1 tmp = None while head : if step % 2 : tmp = ListNode ( head . val ) else : h . next = ListNode ( head . val ) h . next . next = tmp h = h . next . next tmp = None head = head . next step += 1 if tmp : h . next = tmp return dummy . next