Python Program to Print Right Triangle of Mirrored Alphabets Pattern

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

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

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

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

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

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

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

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

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.