break, continue and a loop else to stop both loops.
grid = [[1, 2], [3, -4], [-5, 6]]
found = 0
for row in grid:
for v in row:
if v < 0:
found += 1
break
else:
continue
break
print(found, row, v)
What does the program print?Log in to join the discussion.
Loading…