To clarify about the line pre, node.next, node = node, pre, node.next. We need to understand that the right hand side will be evaluated first before the assignment, and the left hand side will be assigned values one by one, from left to right. (First pre, and then node and the last node.next)

Let's say we have a linked list 1 -> 2 -> 3 -> 4 -> 5. After we found the mid point, we have pre = None, node = 3 -> 4 -> 5

Before we run the multiple assignment:

pre, node.next, node = node, pre, node.next

the original values on the right hand side are: node: 3 -> 4 -> 5, pre: None, node.next: 4 -> 5

And then new pre will store the reference to original node: 3->4->5, and then node.next will refer to original pre: None, which means after these two assignments, we have new pre: 3->None.

At last we assign the original node.next: 4->5 to new node, so the new node has 4->5.

In the next iteration, the right hand side will have node: 4->5, pre:3->None, node.next: 5->None. Then the new pre is going to have 4->5 first, then the old pre will replace the tail of new pre, which makes it 4->3. And new node would have node: 5.

Same as the next iteration.

So this line basically takes out each value in the linked list one by one in order, and then treat each one as tail and append it to the new one.