Print a Rectangle
Beginner · 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 rectangle of stars with 3 rows and 5 columns. Each row should have 5 stars with no spaces between them.
Expected output:
*****
*****
*****# Print a 3x5 rectangle of stars
More Nested Loops exercises
- Predict the OutputIntermediate
- Number TriangleIntermediate
- Sum All Grid ValuesIntermediate
- All Outfit CombinationsIntermediate
- Fix the Coordinate GridIntermediate
All Python exercises · 50 practice problems · Control Flow quiz