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.
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='')
Comments
Leave a comment