Complete the code to stop the loop when the number 3 is found.
for num in range(5): if num == 3: [1] print(num)
The break statement stops the loop immediately when the condition is met.
Complete the code to exit the while loop when count reaches 5.
count = 0 while True: print(count) count += 1 if count == 5: [1]
The break statement exits the loop when count equals 5.
Complete the code to stop the loop when the letter 'a' is found.
letters = ['b', 'c', 'a', 'd'] for letter in letters: if letter == 'a': [1] print(letter)
The break statement stops the loop when 'a' is found.
Fill both blanks to create a loop that prints numbers until it reaches 4, then stops.
for i in range(10): print(i) if i [1] 4: [2]
The condition i == 4 checks when i is 4, and break stops the loop at that point.
Fill all three blanks to create a loop that prints only numbers less than 5 and stops when it reaches 7.
for num in range(10): if num [1] 7: [2] if num [3] 5: print(num)
The first condition checks if num >= 7. The break stops the loop at 7. The last condition prints numbers less than 5.