hi,
Need to find the minimum element value in each row of list a[].if the element of row is equal to the min value, i want to get its column index and put in another list b[].
example:
a[0]=[1,2,3,6,1]
a[1]=[2,3,4,2,5]
a[2]=[3,4,7,3,3]
The minimum in row a[0] is 1. Element of a[0][0] and a[0][4] is equal to 1. So b=[0,4]
But how do i get the index of the column? i tried and got error " 'int' object has no attribute 'index'".
This is what i've done. anyone please help..
Need to find the minimum element value in each row of list a[].if the element of row is equal to the min value, i want to get its column index and put in another list b[].
example:
a[0]=[1,2,3,6,1]
a[1]=[2,3,4,2,5]
a[2]=[3,4,7,3,3]
The minimum in row a[0] is 1. Element of a[0][0] and a[0][4] is equal to 1. So b=[0,4]
But how do i get the index of the column? i tried and got error " 'int' object has no attribute 'index'".
This is what i've done. anyone please help..
Code:
a=[[0 for i in range(5)]for j in range(3)] b=[0 for i in range(10)] a[0]=[1,2,3,6,1] a[1]=[2,3,4,2,5] a[2]=[3,4,7,3,3] for i in range(3): x=min(a[i]) for j in range(5): if(a[i][j]==x): y=a[i][j].index(x) b[j]=y
Comment