0

I've tried to create a 2D array using the format [[None]* N ] * N, but when changing a specific value, say [0][1], it changes the second value in all the sub-arrays. Why is that?
Is the best way to create a 2D array to use a loop?

juanpa.arrivillaga
  • 77,035
  • 9
  • 115
  • 152
Tzvi L
  • 55
  • 6
  • For starters, *these aren't arrays*, these are lists. And yes, using the sequence repetition operator, `*` won't copy items in the list it is used on, so you are create a list with `N` references to the *same list*. – juanpa.arrivillaga Aug 29 '21 at 20:21

0 Answers0