Given an integer N as input, write a program to print a number diamond of 2*N -1 rows as shown below.
n = int(input('N:'))
prefix = ' ' * (n - 1)
ast = '*'
for i in range(1, n):
print(' ' * (n - i), end='')
print('*' * (2 * i - 1))
for i in range(n, 0, -1):
print(' ' * (n - i), end='')
print('*' * (2 * i - 1))
Comments
Leave a comment