Python Tutorial 15: How to quite from a loop in Python

To quite from a loop in python, we use the break function.

For Example:

break statement in python

while True:

In the while statement, we are putting an always true condition so that the loop will always run.

if new_word == ”:
break

If the new_word is “” then, it execute the “break” statement. the “break” statement will break the while loop and then execute the next statement after the while loop. In this case, it is the print statement.

1 thought on “Python Tutorial 15: How to quite from a loop in Python”

Leave a Comment