Nested loops and problem solving
Nested loops and problem solving
A nested loop runs one loop inside another. The total work can grow quickly as collections become larger, so understand the size of each loop. Use clear variable names and consider whether a built-in operation is simpler.
Try it yourself
Change the example, run it, and explain the result in your own words. Then create one variation of your own.
Key idea
Use the example as a starting point, not something to memorize. Practise, inspect the result and make small improvements.
Code example
for row in range(1, 4):
for column in range(1, 4):
print(row * column, end=" ")
print()