in ,

🧑🏻‍💻 TechAcademy | Active engineers explain how to break out of loops with Python [for beginners]

An active engineer explains how to break out of a loop with Python [for beginners]

I will explain how to break out of the loop in Python.

If you're not familiar with Python in the first place, read an article that explains what Python is and get a better understanding.


This article is based on the contents of the TechAcademy online boot camp Python course.



How to use break

The syntax that repeats the process is called the iterative syntax.

Python provides a for and while iterative syntax.Break and continue are provided as ways to break through a repeating loop.Each movement is different, so let's check the contents here.

The first is to use break. With breakThe loop itself is interrupted there for further processing I will move.

For example, the following break works when the variable i is 2.

for i in [1, 2, 3]: if i == 2: print ("i =", i) break ...

→See more in Tech Tech Magazine