Competitive Programming questions in Python |
In this article, we are going to write a python code to print out the hollow rectangle as shown in the Featured Image.
If you are looking for a Python Tutorial Series then it's here
def rectangle(rows, column):
for i in range(1, rows+1):
for j in range(1, column+1):
if (i == 1 or i == rows):
print('*', end='')
elif (j == 1 or j == column):
print('*', end='')
else:
print(' ', end='')
print()
rectangle(8,20)
When you run the code,you will get the following output:
********************
* *
* *
* *
* *
* *
* *
********************
Comments
Post a Comment