I want to make list b
equal to list a
, and then change b
without influencing a.
a = "1234"
b = ""
a = list(a)
b = a
When I print(a)
after changing b
, a
changes as well.
Although in the code below, I don't get this problem, meaning whatever change I make to variable b
, a
will stay independent.
a = "1234"
b = ""
a = list(a)
b = list(a)
I am looking for an explanation on what happened behind the scenes and why the second code example worked.