Nested Loops
Learn and practice using a loop inside another loop.
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 ...
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy