Please enable JavaScript to use CodeHS

Teaching Intro to Computer Science in Python 3

Lesson 4.10 While Loops

Description

  • While loops allow code to be executed repeatedly based on a condition.
  • It might be helpful to think of while loops as a repeating if statement.
  • Infinite loops are created if the exit condition of the while loop is never met, causing the code inside the while loop to repeat continuously.

Objective

Students learn how to effectively use while loops in their programs and to watch out for infinite loops.