Ask Question

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.

+2
Answers (1)
  1. 17 November, 12:53
    0
    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 (" ")

    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
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers