231k views
3 votes
write a program that takes an input from a user for the number of rows and number of columns and prints out a block of characters that is based on these 2 parameters. The program should keep asking the user for input, and printing out the result, until the user enters zero for either of the input parameters.

User Jeff Hill
by
5.3k points

1 Answer

4 votes

Answer:

while True:

rows = int(input("Enter number of rows: "))

columns = int(input("Enter number of columns: "))

if rows == 0 or columns == 0:

break

else:

for _ in range(rows):

for _ in range(columns):

print("*", end=" ")

print(" ")

Step-by-step explanation:

Create a while loop

Ask the user for the number of rows and columns

Check if rows or columns are equal to zero. If at least one of them is zero, stop the loop.

Otherwise, create a nested for loop that iterates according to the rows and columns and prints "*" blocks

User Robaudas
by
5.7k points