0

I want to keep the newlist as is all the time, but want to update newlistcopy each time the loop condition is True. But I can see that newlist and newlistcopy both are getting updated even though I just updated the value of newlistcopy, not newlist:

a=[968, 566, 536, 98, 9, 5]
newlist=[0,3,4,6]
newlistcopy= newlist
newlist_=[]

for i in range(len(newlistcopy)-1):
    for j in range(len(newlistcopy)-1):
        if newlist[j+1]-newlistcopy[j]>=1: 
            newlist_.append(a[newlistcopy[j]])
            newlistcopy[j]+=1
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Nakkhatra
  • 83
  • 10

0 Answers0