What is the output?
x = [[0] * 2] * 2 x[0][0] = 9 print(x)
- [[9, 0], [9, 0]]
- [[9, 0], [0, 0]]
- [[9, 9], [0, 0]]
- Error
The outer multiplication copies the reference, so both rows are the same inner list.
Play Problem Solving ▸
x = [[0] * 2] * 2 x[0][0] = 9 print(x)