Skip to content

Loops

Introduction

Repetition structures allow the same piece of code to run multiple times. Two repetion structures in Python are for loops and while loops. For loops run a set number of times. While loops run as long as a specific logical condition is true.

By the end of this chapter you will be able to:

  • use a while loop

  • use a for loop

  • use the break statement

  • use the continue statement

  • construct flowcharts that describe programs with loops