I know the difference in a[:]
and a
in assignment to a variable and also the special case of slice assignment.
Suppose,
a=[1,2,3,4,5]
What is the difference between the following two statements?
b=a[:]+[6,7,8,9,10] #1
b=a+[6,7,8,9,10] #2
In both cases, both a
and b
have the same values at the end.
I have referred the following links -
When and why to use [:] in python
Python why would you use [:] over =
They haven't mentioned their difference in an expression as such.