0
from pprint import pprint

N = 4
M = 5

visited = [[False] * M for _ in range(N)]
visited2 = [[False] * M] * N

visited[3][2] = True
visited2[3][2] = True

pprint(visited)
pprint(visited2)

print(len(visited))
print(len(visited2))

I don't know why two computation show other results.

enter image description here

  • Please paste your result as text in your question. – Bart Friederichs Jan 04 '22 at 11:08
  • 1
    Does this answer your question? [List of lists changes reflected across sublists unexpectedly](https://stackoverflow.com/questions/240178/list-of-lists-changes-reflected-across-sublists-unexpectedly) – shriakhilc Jan 04 '22 at 11:34

0 Answers0