Printing a rectangle I have an assignment as follows:


  Write a program which reads from the keyboard two integers n and m,
  and a character c from the keyboard. This program should deﬁne and
  call a function: 
  print rectangle(n, m, c) which prints a rectangle of
  size n x m consisting of the character c


My solution is:

n=int(input("Enter the lenght of the rectangle: "))
m=int(input("Enter the width: "))
c="c"
def print_rect(n, m, c):
    for a in range(m):
        print (n*c)
print_rect(n, m, c)
input("Press enter to close")


I am sure there are alternative ways to do this assignment. How would you code this assignment? Do you think my solution is OK?
I think the assignment wants you to read the character from input as well. 

When you are printing the input you are composing the string m times. More optimal solution is if you do that 1 time and output it m times: 

def print_rect(n, m, c):
    row=n*c
    for a in range(m):
        print (row)


I would even do it with this oneliner: 

print((n * c + '\n') * m, end="")