Shaded Diamond
This Program name is Shaded Diamond. Write a Python program to Shaded Diamond
The below link contains Shaded Diamond question, explanation and test cases
https://drive.google.com/file/d/19tuGOTP2lO8EK2sIw1lela2W6qdK0lwY/view?usp=sharing
We need exact output when the code was run
N = int(input())
diamond = []
for i in range(1, N + 1):
line = ' '.join(['*' for x in range(i)])
diamond.append(line.center(2 * N, ' '))
for i in range(N - 1, 0, -1):
line = '*' + ' '.join([' ' for x in range(i - 1)]) + '*'
if i == 1:
line = line[::-2]
diamond.append(line.center(2 * N, ' '))
print('\n'.join(diamond))
Comments
Leave a comment