What does 'Break' do in a loop?

Asked by kemiadewale · 6 months ago

1 Answer

23
amorebise · 6 months ago Top Answer

'Break' is like an emergency exit. It tells the computer: 'I know I said keep going, but something happened—stop the loop right now!'

Maybe you found the person you were looking for in a list. There's no point in looking at the rest of the names, so you 'Break' out to save time.

Log in to add a comment.