0

I just want to ask a simple question I created a list of list and want to change one value in the list by index it:

A = [[0] * 3] * 3
print A, A[0][0]
A[0][0] = 34343
print A

The result is:
[[0, 0, 0], [0, 0, 0], [0, 0, 0]] 0
[[34343, 0, 0], [34343, 0, 0], [34343, 0, 0]]

Why this happens?Where am I wrong?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
stevenhz
  • 57
  • 6

0 Answers0