Answer to Question #213509 in Programming & Computer Science for Sweety

Question #213509

Given the number of rows N,write a program to print the hallow diamond pattern.Note:No space on the left side of the output.


1
Expert's answer
2021-07-05T13:28:32-0400
N = int(input())


left = N-1
middle = -1
letter = 'A'
print(' '*left, letter, sep='')
for _ in range(N-1):
    left -= 1
    middle += 2
    letter=chr(ord(letter)+1)
    print(' '*left, letter, ' '*middle, letter, sep='')
    
for _ in range(N-2):
    left += 1
    middle -= 2
    letter=chr(ord(letter)-1)
    print(' '*left, letter, ' '*middle,letter, sep='')


left += 1
print(' '*left, 'A', 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
APPROVED BY CLIENTS