exactly the same as Reversing a LinkedList in with multiple assignment
but if you try:
pre, node, node.next = node, node.next, pre
it does not work! (getting NoneType
has no attribute next)
both:
pre, node.next, node = node, pre, node.next
and
node.next, pre, node = pre, node, node.next
work. why is the top one wrong? I thought that multiple assignment relieves me from the need to think about the proper order (or to think at all :)
EDIT:
I'll narrow it down:
if node:
node.next, node = None, node.next
#node, node.next = node.next, None # comment the previous line and uncomment this - boom!
I always thought that these lines are equivalent...