Break Out of Loops With Python's break Keyword

Joseph Peart
Joseph Peart 8 Lessons 22m basics python

In Python, the break statement lets you exit a loop prematurely, transferring control to the code that follows the loop. This tutorial guides you through using break in both for and while loops. You’ll also briefly explore the continue keyword, which complements break by skipping the current loop iteration.

By the end of this video course, you’ll understand that:

  • A break in Python is a keyword that lets you exit a loop immediately, stopping further iterations.
  • Using break outside of loops doesn’t make sense because it’s specifically designed to exit loops early.
  • The break doesn’t exit all loops, only the innermost loop that contains it.

What’s Included:

  • 8 Lessons
  • Video Subtitles and Full Transcripts
  • 2 Downloadable Resources
  • Accompanying Text-Based Tutorial
  • Interactive Quiz to Check Your Progress
  • Q&A With Python Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

About Joseph Peart

Joseph is a software developer, data geek, bootcamp instructor, and board game enthusiast. He lives in Canada with his wife and cats. He loves learning new things, teaching those things to other people, and talking about himself in the third person.

» More about Joseph

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses