I\'m trying to find minimum element in matrix row, but there are two conditions:
1) it must be > 0
2) and this point must be not visited(is_visited[k] is False
)
I\'
Try this - it creates the list of x values xs
and then only tries to find the min if xs
is non-empty. You may need to add some logic to handle the case that xs
is empty, depending on what your code is doing.
for k in range(4):
if is_visited[k] is False and i != k:
xs = [x for x in matr_sum[i] if x > 0]
if xs and matr_sum[i][k] == min(xs):
return k