Given an integer
N as input, write a program to print a number diamond of 2*N -1 rows as shown below.
Note: There is a space after each number.
N = int(input())
rows = []
for number in range(1, N + 1):
rows.append(' '.join(['*' for _ in range(1, number + 1)]))
for number in rows[::-1][1::]:
rows.append(number)
diamond = '\n'.join([x.center(2* N - 1) for x in rows])
print(diamond)
Comments
Leave a comment