menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

How to Exi...
source image

RealPython

1w

read

332

img
dot

Image Credit: RealPython

How to Exit Loops Early With the Python Break Keyword

  • The break statement in Python lets you exit a loop prematurely, transferring control to the code that follows the loop.
  • Using break outside of loops doesn’t make sense because it’s specifically designed to exit loops early.
  • The break statement doesn’t exit all loops, only the innermost loop that contains it.
  • You can use the break statement to exit a loop early and prevent unnecessary iterations.

Read Full Article

like

19 Likes

For uninterrupted reading, download the app