Python Centered Alphabet-Palindrome Pyramid (Pattern 46)

Python Code
inc = 1
for x in range(0, 5):
    for y in range(4, x, -1):
        print(" ", end="")
    for z in range(x, -(x + 1), -1):
        print(chr(x - abs(z) + 65), end="")
    print()

Output:

Output of the Python Centered Alphabet-Palindrome Pyramid pattern
BEGINNER WALKTHROUGH

How the Centered Alphabet-Palindrome Pyramid works

The rows form alphabet palindromes such as A, ABA, ABCBA, and ABCDCBA.

01

Build the rows

The outer loop adds one level at a time, and the leading spaces decrease to center the wider rows.

02

Choose what each row prints

The z loop spans both sides of the center; the absolute-distance calculation maps each position to a mirrored letter.

03

Keep the output aligned

The inner print calls use end="" to keep values on the same line. The final empty print() moves to the next row.