How to print rectangle / square pattern in python
In this article we are going to see how to :
Write a program to print dynamic rectangle pattern in python.
height = int(input("Enter the height of the rectangle: "))
width = int(input("Enter the width of the rectangle: "))
i = 0
while(i < height) :
j = 0
while( j < width ):
print(end="* ")
j = j+1
print("")
i = i + 1
Output:
Enter the height of the rectangle: 5
Enter the width of the rectangle: 5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Output 2 :
Enter the height of the rectangle: 5
Enter the width of the rectangle: 10
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
To print hollow rectangle / square, check out the next blog by clicking the next button given below.
Thanks for reading