. Advertisement .
..3..
. Advertisement .
..4..
How to write nested loops to print a rectangle. sample output for giving program: * * * * * *? Below is my code
num_rows = 2
num_cols = 3
'''IDK WHAT TO PUT HERE'''
print('*', end=' ')
print('')
Please give me a few practical suggestions.
Solution:
Here is the easy way for your request “to write nested loops to print a rectangle. sample output for given program: * * * * * *”:
I believe you’re learning, so here’s a hint to help you get started.
A nested
for
loop is required. To create an iterable sequence, use therange()
buildin.The outer loop should be iterative over the number rows. The inner (nested for loop) should iterate around the columns.