Answer:
side = int(input("Please input side length of diamond: "))
# for loop that loop from 0 to n - 1
for i in range(side-1):
# inside the print statement we determine the number of space to print
# using n - 1 and repeat the space
# we also determine the number of asterisk to print on a line
# using 2 * i + 1
print((side-i) * ' ' + (2*i+1) * '*')
# for loop that loop from 0 to n - 1 in reversed way
for i in range(side-1, -1, -1):
# this print statement display the lower half of the diamond
# it uses the same computation as the first for loop
print((side-i) * ' ' + (2*i+1) * '*')
Step-by-step explanation:
The program is written in Python and well commented. The first for loop display the first half of the diamond while the second for loop display the lower half.
A screenshot of program output when the code is executed is attached.