# note the difference between a=b and a= b[:] a = [[1,2],[3,4]] b = a[:] #shallow copy b[1] = [4,5] print a,b ############## # now watch b=a b[1] = [4,5] print a,b # see the difference? Can you explain from this how the global objects are assigned in python? #This is a good excercise.
No comments:
Post a Comment