-1

In the following example, I have a list of 50 elements (lists), each with four elements.


mp = [0] * 4         # List with answers 
mp = [mp] * 50       # List with questions

for i1 in range(len(mp)):
    for i2 in range(len(mp[i1])):
        mp[i1][i2] += 1

Why at the end of the loop, the value is 50 instead of 1? (Each time 1 is added, elements of rest of lists are incremented)

0 Answers0