-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdiamond shape
30 lines (28 loc) · 904 Bytes
/
diamond shape
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
rows = int(input("Enter the number of rows: "))
# It is used to print the space
k = 2 * rows - 2
# Outer loop to print number of rows
for i in range(0, rows):
# Inner loop is used to print number of space
for j in range(0, k):
print(end=" ")
# Decrement in k after each iteration
k = k - 1
# This inner loop is used to print stars
for j in range(0, i + 1):
print("* ", end="")
print("")
# Downward triangle Pyramid
# It is used to print the space
k = rows - 2
# Output for downward triangle pyramid
for i in range(rows, -1, -1):
# inner loop will print the spaces
for j in range(k, 0, -1):
print(end=" ")
# Increment in k after each iteration
k = k + 1
# This inner loop will print number of stars
for j in range(0, i + 1):
print("* ", end="")
print("")