-1

Thanks,

my problem was the following :

list=[1,2] i wanted to copy list into another list: list2=list correct way to do this is : list2=list[:]

Aod Ren
  • 679
  • 1
  • 7
  • 17
  • You should use some more brackets, otherwise the boolean equation is solved linearly, and you will not get the result you expect (according to the `if`-`else`-part later). – arc_lupus Nov 24 '15 at 10:09

1 Answers1

2

r=d just makes r point to the same list as d. It does not make a copy. If you want to modify one without changing the other, you actually do need to make a copy. One way of doing this would be to do

r = d[:]
Daniel Roseman
  • 567,968
  • 59
  • 825
  • 842