Skip to content

Commit 8a5fc9b

Browse files
Create Number Pattern.py
1 parent 6e7f9d5 commit 8a5fc9b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

06 Patterns2/Number Pattern.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'''
2+
Problem statement
3+
Print the following pattern for n number of rows.
4+
5+
Note: each line consist of equal number of characters + spaces. Suppose you are printing xth line for N=n. You need to print 1..x followed by (n-x) spaces, again (n-x) spaces followed by x..1
6+
For eg. N = 5
7+
8+
Sample Input 1 :
9+
4
10+
Sample Output 1 :
11+
'''
12+
13+
n = int(input())
14+
15+
for x in range(1, n+1):
16+
for i in range(1, x+1):
17+
print(i, end="")
18+
for s in range(2*(n-x)):
19+
print(" ", end="")
20+
for j in range(x, 0, -1):
21+
print(j, end="")
22+
print()

0 commit comments

Comments
 (0)