In Python, can someone explain the difference between the use of "s" and "s[:]"? Here, "s" is a sequence type?
Examples:
s = [1,2,3]
s[:] = [1,2,3]
for i in s:
print(i)
for i in s[:]:
print(i)
Are there any differences?
I was thinking maybe the last example means "copy of s" which would allow for modifying s inside loop? What else?
Update based on answers
Thanks everyone. This shows the difference in a very concise way.
>>> s = [1,2,3]; t = s; s[:] = [2,3,4]; print(t)
[2, 3, 4]
>>> s = [1,2,3]; t = s; s = [2,3,4]; print(t)
[1, 2, 3]