Skip to content

Commit b23e9c1

Browse files
committed
add pyramid pattern printing program
1 parent 678dedb commit b23e9c1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

patterns/pyramid_pattern.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Prints a pyramid star pattern.
3+
4+
Example (n = 5):
5+
*
6+
***
7+
*****
8+
*******
9+
*********
10+
"""
11+
12+
def pyramid(n: int) -> None:
13+
for i in range(n):
14+
print(" " * (n - i - 1) + "*" * (2 * i + 1))
15+
16+
17+
if __name__ == "__main__":
18+
pyramid(5)

0 commit comments

Comments
 (0)