Answer to Question #239644 in Python for mansa

Question #239644

Given the number of rows N, write a program to print the hallow diamond pattern with alphabets



1
Expert's answer
2021-09-20T07:48:24-0400
rows = int(input('Please enter number of rows:'))
space = rows
for i in range(1, rows + 1):
    ch = 'A'
    for j in range(1, space):
        print(end=' ')
    space -= 1
    for j in range(1, 2 * i):
        print(ch, end='')
        ch = chr(ord(ch) + 1)
    print()
space = 1
for i in range(1, rows):
    ch = 'A'
    for j in range(1, space + 1):
        print(end=' ')
    space += 1
    for j in range(1, 2 * (rows - i)):
        print(ch, end='')
        ch = chr(ord(ch) + 1)
    print()

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