-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathdiamond_pattern.py
More file actions
36 lines (30 loc) · 842 Bytes
/
diamond_pattern.py
File metadata and controls
36 lines (30 loc) · 842 Bytes
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
31
32
33
34
35
36
# Python program to print The Diamond Pattern.
def Diamond(rows):
n = 0
for i in range(1, rows + 1):
# loop to print spaces
for j in range (1, (rows - i) + 1):
print(end = " ")
# loop to print star
while n != (2 * i - 1):
print("*", end = "")
n = n + 1
n = 0
# line break
print()
k = 1
n = 1
for i in range(1, rows):
# loop to print spaces
for j in range (1, k + 1):
print(end = " ")
k = k + 1
# loop to print star
while n <= (2 * (rows - i) - 1):
print("*", end = "")
n = n + 1
n = 1
print()
# Finally how many rows of dimaoond you want we can specify.
rows = 5
Diamond(rows)