Python Program to Print Triangle of Mirrored Numbers Pattern

Write a Python program to print triangle of mirrored numbers pattern using for loop.

rows = int(input("Enter Triangle Mirrored Numbers Rows = "))

print("====The Triangle of Mirrored 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(k, end = '')
    for l in range(i - 1, 0, -1):
        print(l, end = '')
    print()
Python Program to Print Triangle of Mirrored Numbers Pattern

This Python pattern example prints the triangle of mirrored numbers using a while loop.

rows = int(input("Enter Triangle Mirrored Numbers Rows = "))

print("====The Triangle of Mirrored Numbers Pattern====")
i = 1

while(i <= rows):
    j = rows
    while(j > i):
        print(end = ' ')
        j = j - 1
    k = 1 
    while(k <= i):
        print(k, end = '')
        k = k + 1
    l = i - 1
    while(l >= 1):
        print(l, end = '')
        l = l - 1
    print()
    i = i + 1
Enter Triangle Mirrored Numbers Rows = 9
====The Triangle of Mirrored Numbers Pattern====
        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.