printing a diamond in python code example
Example: smallest program to make diamond python
h = eval(input("please enter diamond's height:"))
for i in range(h):
print(" "*(h-i), "*"*(i*2+1))
for i in range(h-2, -1, -1):
print(" "*(h-i), "*"*(i*2+1))
# please enter diamond's height:4
# *
# ***
# *****
# *******
# *****
# ***
# *
#
# 3, 2, 1, 0, 1, 2, 3 space
# 1, 3, 5, 7, 5, 3, 1 star
# please enter diamond's height:5
# *
# ***
# *****
# *******
# *********
# *******
# *****
# ***
# *
#
# 4, 3, 2, 1, 0, 1, 2, 3, 4 space
# 1, 3, 5, 7, 9, 7, 5, 3, 1 star