[Python] Can you hold pointers in a python list?

Discussão em 'Python' iniciado por Stack, Novembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    For example

    b = 4
    c = []

    c.append(b)

    print(c)

    b += 2

    print(c)


    I was hoping I would get

    4
    6


    but I got

    4
    4


    Any chance I could add the element as a pointer. And then if I reference that element with c[0] I'd be referencing the b?

    Continue reading...

Compartilhe esta Página