I am trying to solve a LeetCode question- Reorder List.In the process of solving it, Iv'e only managed to fix a bug in reversing the list with the help of chatGPT, but don't really understand how it is possible.I have learned that if u attempt to do multiple assigns in one line, the right part is always fully evaluated and then the assigning occur.Anyone can help me with why the line in comment which was originally my code, is wrong and leading to error?
class Solution(object): def reorderList(self, head):""" :type head: ListNode :rtype: None Do not return anything, modify head in-place instead.""" s, f = head, head while f.next and f.next.next: s = s.next f = f.next.next def reverse(h): prev = None while h: # h, h.next, prev= h.next, prev, h prev, h.next, h = h, prev, h.next return prev h1, h2 =head, reverse(s.next) while h2: h2, h1.next, h1 = h1.next, h2, h2 h1.next=h2