Skip to content

Commit 7826b28

Browse files
committed
Python Program to print a diamond pattern
1 parent 9d1b302 commit 7826b28

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

patterns/DiamondPattern.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
__author__ = 'Avinash'
2+
3+
# Print a Diamond
4+
5+
# *
6+
# * *
7+
# * * *
8+
# * * * *
9+
# * * * * *
10+
# * * * *
11+
# * * *
12+
# * *
13+
# *
14+
15+
# Range of the diamond
16+
num = int(input("Enter the range: \t "))
17+
18+
# pyramid
19+
for p in range(num):
20+
print(' '*(num-p-1)+'* '*(p+1))
21+
# reverse pyramid
22+
for rp in range(num-1, 0, -1):
23+
print(' '*(num-rp)+'* '*rp)

0 commit comments

Comments
 (0)