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)
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments