Without using numpy, my question is related to the for loop in Python, as it doesn't have for i=0, i++ ...
only
for i in list
I need
for i in list
# print(i.index)
# i.index being 0 at the first element of the list and
# ordered to len(list)-1 at the last element
There is something I am missing :
mat=[[1,0,1],
[1,1,1],
[1,0,1]]
dict1= []
dict2= []
n=len(mat[0])
for row in mat :
for j in range(n):
if row[j]==0:
dict1.append(mat.index(row))
dict2.append(j)
print(dict1)
print(dict2)
output should be [0,2] and [1,1] but instead I am getting
[0,0]
[0,1]
How do we explain this?