[Python] Why python call by reference is so unruly

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    arr = [1]

    def f1(lst):
    lst.append(2)
    print(lst)
    lst = 2
    print(lst)

    f1(arr)
    print(arr) # [1,2]


    why python call by reference parameter does not change to value?

    what does lst variable indeicating when do "lst = 2" (not connected to arr?)

    Continue reading...

Compartilhe esta Página