Given an integer N, Write a program to print a pyramid of N rows as shown below.
In the example the number of rows in tbe pyramid is 5. So, the output shoyld be
. . . . 0 . . . .
. . . 0 0 0 . . .
. . 0 0 0 0 0 . .
. 0 0 0 0 0 0 0 .
0 0 0 0 0 0 0 0 0
#Getting an input from the User
n = int(input())
#Looping through the n and creating the pyramid
for a in range(n):
print('. ' * (n - a - 1), end='')
print('0 ' * (2 * a + 1), end='')
print('. ' * (n - a - 1), end='')
print()
Comments
Leave a comment