-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAssignment 5.py
21 lines (19 loc) · 982 Bytes
/
Assignment 5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
while True:
n = int(input("Enter number of row: ")) # It computes the number of rows to be printed
for i in range(1,n+1): # It iterates through each row and executes the if statement below when the condition holds
if i == 1:
for q in range(n):
print(" ", end = '')
print("*")
for j in range(n - i - 1): # It iterates each column in the specified range and print spaces depending on the given range
print(' ', end='')
for j in range(3 * i+2): # It iterates through each row and executes the if statement below when the condition holds
if j == 0 :
print('* ', end='')
elif j == 2 * i:
print(" *", end = '')
elif j == i:
print(i,end ='')
else:
print(' ', end='')
print()