[Python] Should setting A to B then changing A affect B in python?

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

  1. Stack

    Stack Membro Participativo

    a = [0,0]
    b = a
    a[0] = 1
    print(b)


    This code returns [1,0]

    Shouldn't it return [0,0]?

    Is there any way to bypass this bug/feature? (to have it return [0,0])

    I probably have used code very similar to this in the past, there weren't any problems before...

    Continue reading...

Compartilhe esta Página