It is said Lists in python are mutable. When I write code like below,
l1=[6,7,8,4,3,10,22,4]
l2=l1
l1.append(30)
print(l1)
print(l2)
both l1 and l2 prints the same list: [6, 7, 8, 4, 3, 10, 22, 4, 30]
But when i give code like below,
l1=[6,7,8,4,3,10,22,4]
l2=l1
l1=l1+[30]
print(l1)
print(l2)
l1
prints --> [6, 7, 8, 4, 3, 10, 22, 4, 30]
l2
prints --> [6, 7, 8, 4, 3, 10, 22, 4]
So, now there references have changed. So are lists in python really mutable?