Skip to content

Commit 3a1225b

Browse files
Merge pull request #270 from SanskarSh/Sanskar-266
Adding code for pattern
2 parents b8ae59c + 2ade053 commit 3a1225b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Pyramid Pattern 3
2+
3+
**Pattern Image:**
4+
5+
![image](../../img/pyramidpattern3.PNG)
6+
7+
**Contributor:** [Sanskar Shrivastava](https://github.com/SanskarSh)
8+
9+
:star2: Star it :fork_and_knife:Fork it :handshake: Contribute to it!
10+
11+
Discord server - http://pragmaticprogrammer.in/discord
12+
13+
Happy Coding :purple_heart:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set the number of rows for the pattern
2+
n = 5
3+
4+
# Loop through rows from 1 to 'n'.
5+
for i in range(1, n + 1):
6+
7+
# Loop to print spaces before the numbers in each row.
8+
for k in range(1, n - i + 1):
9+
print(" ", end=" ")
10+
11+
# Loop to print numbers in ascending order in each row.
12+
for j in range(1, i + 1):
13+
print(j, end=" ")
14+
15+
# Move to the next line to start a new row.
16+
print()

0 commit comments

Comments
 (0)