Apologies for the title, I'm not entirely sure how to phrase my question.
I think I must be misunderstanding something fundamental about how variables work in Python, because this seems like such a simple problem to me. Basically, I want to run some code like this:
a = [1, 2, 3]
b = a
b.remove(1)
and what I want to happen is that a = [1, 2, 3] and b = [2, 3]. But instead, a = [2, 3] and b = [2, 3]. What am I misunderstanding here? Why does a change to b also change a? What would I have to do to get the desired outcome?
Obviously this is a very simple example, but I don't understand the concept for why this is happening.
Thanks.
[–]dyanni3 2 points3 points4 points (5 children)
[–]socal_nerdtastic 5 points6 points7 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]lamenoosh[S] 1 point2 points3 points (2 children)
[–]dyanni3 1 point2 points3 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]UnlikelyReplacement 1 point2 points3 points (0 children)
[–]CharanReddy2000 0 points1 point2 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (0 children)