So I just started learning python and I am trying to make a rectangle out of the same recurring character, for example if height=5 and width=3, and the character is 'P,' a 5x3 rectangle of P's would be created:
PPPPP
PPPPP
PPPPP
But how do I write a program that does it. How would I go about doing this? I know I have to use "for" loops but I'm not exactly sure what I have to do. Thanks The code I have so far is:
def width_of_rectangle(width_size):
for current_length in range(width_size):
print('P',end='')
def height_of_rectangle(height_size):
for current_height in range(height_size):
width_of_rectangle(current_lenght)
print('P',end='')
But it is making a triangle instead of a rectangle because it is not repeated the same number of times, it comes out as:
P
PP
PPP
PPPP
PPPPP
I know I'm doing something wrong but not sure what it is