I am new to python and I am trying to run following code:
m=int(raw_input())
l=[[0]*2]*m
for i in range(0,m):
for j in range(0,2):
l[i][j]=raw_input()
print l
print "-------"
Output:
3
1
[['1', 0], ['1', 0], ['1', 0]]
-------
2
[['1', '2'], ['1', '2'], ['1', '2']]
-------
3
[['3', '2'], ['3', '2'], ['3', '2']]
-------
4
[['3', '4'], ['3', '4'], ['3', '4']]
-------
5
[['5', '4'], ['5', '4'], ['5', '4']]
-------
6
[['5', '6'], ['5', '6'], ['5', '6']]
but, when i dry run the program the expected output should be
3
1
[['1', 0], ['1', 0], ['1', 0]]
-------
2
[['1', '2'], ['1', '2'], ['1', '2']]
-------
3
[['1', '2'], ['3', '2'], ['1', '2']]
-------
4
[['1', '2'], ['3', '4'], ['1', '2']]
-------
5
[['1', '2'], ['3', '4'], ['5', '2']
-------
6
[['1', '2'], ['3', '4'], ['5', '6']]
Its like after each iteration list is reassigned, but as I am incrementing 'i' list elements should be like the expected output. Please i need help..