-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHolo Diamond Pattern.py
More file actions
50 lines (37 loc) · 1017 Bytes
/
Holo Diamond Pattern.py
File metadata and controls
50 lines (37 loc) · 1017 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Python program to print a hollow
# diamond pattern
def printPattern(n):
k = 0;
# Print upper triangle
for i in range(1, n + 1):
# Print spaces
for j in range(1, n - i + 1):
print(" ", end="")
# Print #
while (k != (2 * i - 1)):
if (k == 0 or k == 2 * i - 2):
print("*", end="")
else:
print(" ", end="")
k = k + 1
k = 0
# move to next row
print(""),
n = n - 1
# Print lower triangle
for i in range(n, 0, -1):
# Print spaces
for j in range(0, n - i + 1):
print(" ", end="")
# Print #
k = 0
while (k != (2 * i - 1)):
if (k == 0 or k == 2 * i - 2):
print("*", end="")
else:
print(" ", end="")
k = k + 1
print(""),
# Driver code
n = 6
printPattern(n)