0

I a beginner in python and I'm struggling in a code to modify a 2d list in a loop 'for'

Here is my code

```
def test() :
    L=[[0]*2]*2
    for i in range (2) :
        for j in range (2) :
            L[j][i]=1
            print(L)
```

And it returns to me ... :

```
test()
[[1, 0], [1, 0]]
[[1, 0], [1, 0]]
[[1, 1], [1, 1]]
[[1, 1], [1, 1]]

```

It is normaly supposed to work ^^ Thanks for your help !

UnholySheep
  • 3,967
  • 4
  • 19
  • 24

0 Answers0