I would like to know why a is not changed in the code below, but f is changed.
After assigning 5 to c[0], a remains 2 and c[0] changes from 2 to 5. This makes sense to me because I did not assign a value to a. After assigning 8 to t[0][0], f[0] is changed from 1 to 8. This does not make sense to me, because I am changing t not f.
a = 2
b = 3
c = [a,b]
print(c)
print(a)
c[0]= 5
print(c)
print(a)
f = [1,1,1]
s = [2,2,2]
t = [f,s]
print(t)
print(f)
t[0][0] = 8
print(t)
print(f)
output:
[2, 3]
2
[5, 3]
2
[[1, 1, 1], [2, 2, 2]]
[1, 1, 1]
[[8, 1, 1], [2, 2, 2]]
[8, 1, 1]