Skip to content
dreamcode
dreamcode
Back to map
Nested loops · Lesson 13 of 44
+15 XP on finish
PYTHON BASICS

Loops inside loops

A loop inside another loop is a nested loop. The inner loop runs completely from start to finish for each turn of the outer loop. We can also accumulate values inside a loop.

How it reads
The inner loop runs 2 times for each of the outer loop's 3 turns (6 times total)
total = total + 1 accumulates the count
Cloud tip: Nested loops are common for working with grids, tables, coordinates, or multi-dimensional data.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -