Number Triangle
Intermediate · Write the code · from Nested Loops: Patterns, Performance, and When to Avoid Them
From the lesson: Nested Loops: Patterns, Performance, and When to Avoid Them
Think about a spreadsheet. It has rows and columns. To read every cell, you go through each row, and for each row, you go through each column. That's two loops - one inside the other. That's a nested loop.
Read the lessonPrint a number triangle where each row contains the row number repeated. The triangle has 4 rows.
Expected output:
1
22
333
4444# Print a number triangle with 4 rows
More Nested Loops exercises
- Print a RectangleBeginner
- Predict the OutputIntermediate
- Sum All Grid ValuesIntermediate
- All Outfit CombinationsIntermediate
- Fix the Coordinate GridIntermediate
All Python exercises · 50 practice problems · Control Flow quiz