Today i am reading a book and found that list can be assign like x = list[:], but befor i read that i assign list like x=list But what is the difference ? Assume that lis = [1,2,34,5,1,243,34] is a list. Now i assign the lis to lis_a,lis_b and lis_c
>>> lis = [1,2,34,5,1,243,34]
>>> lis_a = lis
>>> lis_b = lis[:]
>>> lis_c = lis
when i print all those variables value then the output is same.
>>> print(lis,'\n',lis_a,'\n',lis_b,'\n',lis_c)
[1, 2, 34, 5, 1, 243, 34]
[1, 2, 34, 5, 1, 243, 34]
[1, 2, 34, 5, 1, 243, 34]
[1, 2, 34, 5, 1, 243, 34]
But when i print the id of those variable then the values are same expect lis_b because i assign lis_b by lis[:]
print(id(lis),'\n',id(lis_a),'\n',id(lis_b),'\n',id(lis_c))
45131136
45131136
45130016 <-- this is for lis_b
45131136
Why this happend ? Is there any time complexity behind it ?