Write a program to print a rectangle pattern of M rows and N columns using the characters as shown below.
In the given example,
3 rows and 10 columns.Therefore, the output should be
+----------+
| |
| |
| |
+----------+
def main():
n, m = map(int, input('Enter rectangle size').split())
if n < 2 or m < 2:
print('Please enter bigger dimention!')
return
for i in range(1, n+1):
for j in range(1, m+1):
if (i == 1 and j == 1) or (i == 1 and j == m) or (i == n and j == 1) or (i == n and j == m):
print('+', end='')
elif i == 1 or i == n:
print('-', end='')
elif j == 1 or j == m:
print('|', end='')
else:
print(' ', end='')
print()
main()
Comments
Leave a comment