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()
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