0

I've initialized a 2d array and then tried to initialize all the values of the first row to 0.

saved_results = [[None] * (c + 1)] * (len(v) + 1)

for i, j in enumerate(saved_results[0]):
    saved_results[0][i] = 0

Instead of

[
[0, 0, 0],
[None, None, None],
[None, None, None]
]

I get

[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]

I'm not sure if I'm overlooking something simple. What am I missing?

Jacob L
  • 133
  • 2
  • 18

0 Answers0