a = [1,2,3,4]
b = a
b[0] = 10
print a
I haven't touched the numbers in list a, but they still change. Why does this happen? Also, this seems to return the expected result:
a = [1,2,3,4]
b = a[:]
b[0] = 10
print a
Can somebody tell me what [:] does and why the first code changes a?