Link Search Menu Expand Document

Loops

Table of contents

  1. Description
  2. Looping Techniques
  3. Python Control Structures
  4. Video Tutorials

Description

Loops allow programmers to repeat a block of code several times. The Python language includes two types of loops, each used for specific purposes:

  • while loops: Loop body will continue executing until a condition fails.
  • for loops: Loop body will execute a specified number of times, or for each item of a container (like characters in a string).

Looping Techniques

Python docs has outlined many useful patterns to use when looping over sequences and dictionairies: Looping Techniques

Python Control Structures

Loops are one of three program control structures. These control structures dictate the order in which a program’s code executes:

  • Sequential: Code is executed linearly, one after the other.
  • Selection: Different block(s) of code are executed based on the results of a condition.
  • Iteration: Repeating a block of code several times.

Video Tutorials