multiplication 과 for문의 차이
- multiplication
1 | 1]*8]*8 a = [[ |
- for
1 | 1 for i in range(8)] for j in range(8)] A = [[ |
In your first version, you’re creating a list containing the number 1 and by multiplying it 8 times create a list containing 8 1s, and using that list 8 times to create a
.
So when you change anything in the first version, you’ll see that change everywhere else. Your problem being that you’re reusing the same instance, something that doesn’t happen in the second version.