Sometimes, instead of break, you can have a loop remember where it found an item, but then continue with all iterations. Here, the example uses nested iteration, to search through a matrix of numbers for the first even number.

1
2
3
4
5
search = None
for i in range(len(M)):
  for j in range(len(M[i])):
    if search == None and M[i][j]%2 == 0:
       search = M[i][j]

When this loop finishes, the variable "search" will be equal to the first even number in matrix M (or possibly None, if there is no such number). Notice how the if-statement condition tests both for an even number and for whether or not some previous iteration already found an even number. This is a known pattern in toolbox of loop writing.