In this exercise, a
break statement is used as the last line in the
for loop. If there was any additional code in the
for loop after the break, would it execute?
break statement will terminate the execution of the
for loop. It does not allow for the execution of any additional code in the loop if it exists. In other words,
break doesn’t stop the loop from completing any new iterations, it completely stops the current iteration at the point
break is placed.
In the following example code, the
print(counter) statement is called for numbers 1 through 4 but does not print the value 5.
counter = 0 while counter < 10: counter += 1 if counter == 5: print("Reached 5") break print(counter)