Skip to content

Commit 40a7cd0

Browse files
Create 3_1.py
1 parent 7a4d9ff commit 40a7cd0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pattern/3_1.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
n=int(input("enter a number: "))
2+
for i in range(1,n+1):
3+
print(' '*(i-1),'*',sep='',end="")
4+
print(' '*(2*(n-i)-1),'*' if i!=n else "",sep='')
5+
#print(' '*(2*(n-i)-1),'*',sep='') if i!=n else print()
6+
for i in range(n-1,0,-1):
7+
print(' '*(i-1),'*',sep='',end="")
8+
print(' '*(2*(n-i)-1),'*',sep='')
9+
'''
10+
output:
11+
enter a number: 7
12+
* *
13+
* *
14+
* *
15+
* *
16+
* *
17+
* *
18+
*
19+
* *
20+
* *
21+
* *
22+
* *
23+
* *
24+
* *
25+
'''

0 commit comments

Comments
 (0)