Possible Duplicate:
Python 2D list has weird behavor when trying to modify a single value
folks,
I am wondering if the two following statements are the same?
a = [[0]*3]*3
b = [[0]*3 for i in range(3)]
The results look the same. But would one way be better than the other? What is the difference here.
Thanks very much for your help.
nos
They’re not the same
The first one creates an outer array of pointers to a single inner array while the second actually creates 3 separate arrays.