Shaded Diamond
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.
print("Input value of n (odd):")
n=int(input())
x=n//2+1
for i,j in zip(range(1,x+1),range(1,n+1,2)):
print(' '*(x-i)+'*'*(j))
for i,j in zip(range(1,x+1),range(n-2,-1,-2)):
print(' '*(i)+'*'*(j))
Sample input 1:
5
Sample Output 1:
*
***
*****
***
*
Comments
Leave a comment