-2

Hi I tried to copy a list within a list as shown below.

top = best[0]

then I made a modification on variable 'best' and somehow variable 'top' also changes. I know this because I append some elements to the variable 'best'. How do I make sure the value of the variable 'top' stays the same?

Thank you

muka lipan
  • 47
  • 4

1 Answers1

0

You could try top = best[0].copy().

arckoor
  • 320
  • 3
  • 13