Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.
Python has two types of loop statements: For loop: Used when the number of iterations is known before the loop starts. While loop: Repeats as long as a certain condition is true.
Here are some examples of when you might use each loop:
For loop: Iterate over a list of items Perform a set number of iterations
While loop: Iterate until a condition is met Perform an unknown number of iterations
You can also use nested loops, which are loops that are placed inside of other loops. Nested loops can be useful for performing complex tasks.
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.