Answer to Question #258064 in Python for Pavani

Question #258064

given an integer N as input write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) .


1
Expert's answer
2021-10-28T07:10:55-0400
n = int(input())
for i in range(n):
    lst = [' '] * (2 * n - 1)
    lst[n - 1 - i] = '*'
    lst[-n + i] = '*'
    print(*lst, sep='')
for i in range(n - 2, -1, -1):
    lst = [' '] * (2 * n - 1)
    lst[n - 1 - i] = '*'
    lst[-n + i] = '*'
    print(*lst, sep='')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog