course content

Course Content

Introduction to Python

Nested LoopsNested Loops

Just as you can nest lists within lists or tuples within tuples, you can also loop through elements that are already being looped over. For example, you can loop through a list that contains other lists.

Note

In this code, j represents each element within the nested lists inside the countries list. As the nested loop iterates, j takes on the values of each element in the inner lists, which are then printed.

Everything was clear?

Section 5. Chapter 8