Python Program to Print Pyramid Numbers Pattern

Write a Python program to print pyramid numbers pattern using for loop.

rows = int(input("Enter Numbers Pyramid Pattern Rows = "))

print("====The Pyramid of Numbers Pattern====")

for i in range(1, rows + 1):
    for j in range(rows, i, -1):
        print(end = ' ')
    for k in range(1, i + 1):
        print(i, end = ' ')
    print()
Python Program to Print Pyramid Numbers Pattern

This Python example program prints the pyramid pattern of numbers using a while loop.

rows = int(input("Enter Rows = "))

print("========")
i = 1

while(i <= rows):
    j = rows
    while(j > i):
        print(end = ' ')
        j = j - 1
    k = 1
    while(k <= i):
        print(i, end = ' ')
        k = k + 1
    print()
    i = i + 1
Enter Rows = 9
========
        1 
       2 2 
      3 3 3 
     4 4 4 4 
    5 5 5 5 5 
   6 6 6 6 6 6 
  7 7 7 7 7 7 7 
 8 8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 9