[Python] swap mechanism - linked list

Discussão em 'Python' iniciado por Stack, Setembro 23, 2024.

  1. Stack

    Stack Membro Participativo

    I would have thought this is the same thing but it's not

    This is not working

    cur, cur.next, prev = cur.next, prev, cur


    This is working

    cur.next, cur, prev = prev, cur.next, cur


    on several lines:

    tmp = cur.next
    cur.next = prev
    prev = cur
    cur = tmp


    I am trying to understand the internal mechanism of python

    Continue reading...

Compartilhe esta Página