I understand that given this code
a = [1,2,3]
b = [4,5,6]
c = a
and then by doing this
a[0] = 0
I wil change first positions of both a and c. Could somebody explain why this doesn't apply when I do this:
a = b
ie. why c doesn't become equal to b?
a = [1,2,3]
b = [4,5,6]
# a ────────> [1,2,3]
# b ────────> [4,5,6]
c = a # Changing 'c' to point at the list that 'a' points at
# c ─────┐
# a ─────┴──> [1,2,3]
# b ────────> [4,5,6]
a = b # Changing 'a' to point at the list that 'b' points at
# c ─────┐
# a ──┐ └──> [1,2,3]
# b ──┴─────> [4,5,6]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With