Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python diamond

h = eval(input("Enter diamond's height: "))
for x in range(h):
    print(" " * (h - x), "*" * (2*x + 1))
for x in range(h - 2, -1, -1):
    print(" " * (h - x), "*" * (2*x + 1))
#OUTPUT
# Enter diamond's height: 4
#      *
#     ***
#    *****
#   *******
#    *****
#     ***
#      *
 
PREVIOUS NEXT
Tagged: #python #diamond
ADD COMMENT
Topic
Name
9+8 =