Code:
n = int(input('Enter the number of rows:'))
i = 1
while i <= n:
j = n
while j > i:
# display space
print(' ', end= ' ')
j -= 1
print('* ', end= ' ')
k = 1
while k < 2 * (i - 1):
print(' ', end= ' ')
k += 1
if i == 1:
print()
else:
print('* ')
i += 1
i = n - 1
while i >= 1:
j = n
while j > i:
print(' ', end= ' ')
j -= 1
print('* ', end= ' ')
k = 1
while k < 2 * (i - 1):
print(' ', end= ' ')
k += 1
if i == 1:
print( )
else:
print('*')
i -= 1
Output:
![](https://static.wixstatic.com/media/0f65e1_2665e5df141a46b69b07e763fb0d84d7~mv2.png/v1/fill/w_71,h_23,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/0f65e1_2665e5df141a46b69b07e763fb0d84d7~mv2.png)
The Tech Platform