Given an integer value
N as input, write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) character as shown below.
Note: There is a space after each asterisk (*) character.
*
* *
* * *
* * * *
* * * * *
* *
* *
* *
*
n = int(input())
for i in range(n):
s = ' '*(n - i - 1)
s += '* '* (i + 1)
print(s)
for j in range(n-1):
s = ' '*(j + 1)
s += '*' + ' '*(n - (2*j)) + '*'
if j == (n - 2):
s = ' '*(n - 1) + '*'
print(s)
Comments
Leave a comment