Nested Loops
Learn and practice using a loop inside another loop.
We'll cover the following...
We'll cover the following...
Nested loop
When we use a loop inside another loop, we call them nested loops. The first loop is called the outer loop, and the second loop is called the inner loop. Nested loops may be the same type or different types of loops. Both loops may be for loops or while loops. The outer loop may be a for loop and the inner loop a while loop, or vice versa.
Let’s use the Cartesian product of two sets as an illustration of nested loops.
Cartesian product
The Cartesian product of the sets and is ...