Python Program to Print Triangle of Mirrored Alphabets Pattern

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

rows = int(input("Enter Triangle of Mirrored Alphabets Rows = "))

print("====The Triangle of Mirrored Alphabets Pattern====")
alphabet = 65

for i in range(rows):
    for j in range(rows - 1, i - 1, -1):
        print(end = ' ')
    for k in range(i + 1):
        print('%c' %(alphabet + k), end = '')
    for l in range(i - 1, -1, -1):
        print('%c' %(alphabet + l), end = '')
    print()
Python Program to Print Triangle of Mirrored Alphabets Pattern

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

rows = int(input("Enter Triangle of Mirrroed Alphabets Rows = "))

print("====The Triangle of Mirrored Alphabets Pattern====")
alphabet = 65
i = 0

while(i < rows):
    j = rows - 1
    while(j >= i):
        print(end = ' ')
        j = j - 1
    k = 0
    while(k <= i):
        print('%c' %(alphabet + k), end = '')
        k = k + 1
    l = i - 1
    while(l >= 0):
        print('%c' %(alphabet + l), end = '')
        l = l - 1
    print()
    i = i + 1
Enter Triangle of Mirrroed Alphabets Rows = 11
====The Triangle of Mirrored Alphabets Pattern====
           A
          ABA
         ABCBA
        ABCDCBA
       ABCDEDCBA
      ABCDEFEDCBA
     ABCDEFGFEDCBA
    ABCDEFGHGFEDCBA
   ABCDEFGHIHGFEDCBA
  ABCDEFGHIJIHGFEDCBA
 ABCDEFGHIJKJIHGFEDCBA

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.