given a integer valun N as input, write a program to print a shaded diamond of 2*N-1 rows using astherisk(*) character..
n = int(input('Enter N: '))
print(' ' * (n - 1) + '*' + ' ' * (n - 1))
for i in range(1, n - 1):
print(' ' * (n - i - 1) + '*' + ' ' * (2 * i - 1) + '*' + ' ' * (n - i - 1))
print('*' + ' ' * (2 * (n - 1) - 1) + '*')
for i in range(-n + 2, 0):
print(' ' * (n - -i - 1) + '*' + ' ' * (2 * -i - 1) + '*' + ' ' * (n - -i - 1))
print(' ' * (n - 1) + '*' + ' ' * (n - 1))
Comments
Leave a comment