# Find the first number divisible by 7for i inrange(1, 100):
if i % 7 == 0:
print(f"First multiple of 7: {i}")
break# Break out of a while loop
password = ["wrong", "wrong", "correct", "wrong"]
attempt = 0while attempt < len(password):
if password[attempt] == "correct":
print(f"Access granted on attempt {attempt + 1}")
break
attempt += 1
Output
Click "Run" to execute your code
break immediately exits the innermost loop. Code after break in the loop body is skipped.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?