1h = eval(input("please enter diamond's height:"))
2
3for i in range(h):
4 print(" "*(h-i), "*"*(i*2+1))
5for i in range(h-2, -1, -1):
6 print(" "*(h-i), "*"*(i*2+1))
7
8# please enter diamond's height:4
9# *
10# ***
11# *****
12# *******
13# *****
14# ***
15# *
16#
17# 3, 2, 1, 0, 1, 2, 3 space
18# 1, 3, 5, 7, 5, 3, 1 star
19
20# please enter diamond's height:5
21# *
22# ***
23# *****
24# *******
25# *********
26# *******
27# *****
28# ***
29# *
30#
31# 4, 3, 2, 1, 0, 1, 2, 3, 4 space
32# 1, 3, 5, 7, 9, 7, 5, 3, 1 star
1num = 9
2
3for i in range(1, num+1):
4 i = i - (num//2 +1)
5 if i < 0:
6 i = -i
7 print(" " * i + "*" * (num - i*2) + " "*i)
8