I need print the coordinates of matrix whose corresponding row and columns are only zeros
Example:
3 3
1 0 0
0 0 0
1 0 0
in above example at coordinate (1,1) rows and cols are zero(0) like that I need to print all coronates having row and col as zero.(like need to check in plus shape)
My code:
r,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(r)]
for i in range(len(l)):
for j in range(0,len(l[i])):
if sum(l[i])==0 and sum(l[j])==0:
print(i,j)
my code is working for above mentioned input but for bellow mention input not working why??
input:
6 13
1 0 1 0 1 0 1 0 1 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1 0 1 0 1 0
output needed:
1 13
2 13
3 13
4 13
my output:
1 1
1 2
1 3
1 4
Traceback (most recent call last):
File "main.py", line 5, in <module>
if sum(l[i])==0 and sum(l[j])==0:
IndexError: list index out of range
What mistake i made? Please help me!!