cars = ["ok", "ok", "ok", "faulty", "ok", "ok"]
for status in cars:
if status == "faulty":
print("Stopping the production line!")
break
print(f"This car is {status}.")
Output:
This car is ok.
This car is ok.
This car is ok.
Stopping the production line!