[Solved] how does python assignment(=) operator work


In Python, evaluation is in reverse order. Therefore this:

node = node.next = ListNode(10)

is the same as this:

node = ListNode(10)
node.next = node

So, you have to reverse order of elements before last assignment:

node.next = node = ListNode(10)
# same as:
node.next = ListNode(10)
node = node.next

4

solved how does python assignment(=) operator work