a=[1,2,3,4,5]
b=a
a.sort()
what are the values of a and b now? I am getting both a and b are same. But how to make it different
a=[1,2,3,4,5]
b=a
a.sort()
what are the values of a and b now? I am getting both a and b are same. But how to make it different
One way is to initialize b=[] and append all elements of a to b, one by one.
a=[1,2,3,5,4] #Let's say
b=[]
for i in a:
b.append(i)
a.sort()
Now a and b will be different.