How do I stop a loop early?

Asked by blessing007 · 6 months ago

1 Answer

44
amorebise · 6 months ago Top Answer

We use the break command. It’s like an emergency exit. If you are looking for a specific name in a list of 1,000 students, once you find it, there’s no need to look at the rest.

You just say break, and Python jumps out of the loop immediately. It’s a great way to save the computer's energy.

Log in to add a comment.