In [1]: mat = [[0]*26]*5 In [2]: id(mat[0]) Out[2]: 140082606853896 In [3]: id(mat[1]) Out[3]: 140082606853896As you can see the list elements are one object.
Use list comprehension instead.
mat = [0 for _ in range(26)] for range(5)]]See this video: https://www.youtube.com/watch?v=F6u5rhUQ6dU