Python Twin-Pyramid Star Pattern (Pattern 99)

Python Code
ph = 5  # height
ps = ph - 1  # space
inc = 1  # min star

for x in range(0, ph):
    for y in range(ps, x, -1):
        print(" ", end="")
    for z in range(0, inc):
        print("*", end="")

    for y in range(ph + ph - 2, inc - 1, -1):
        print(" ", end="")
    for z in range(0, inc):
        print("*", end="")

    inc += 2
    print()

Output:

Output of the Python Twin-Pyramid Star Pattern pattern
BEGINNER WALKTHROUGH

How the Twin-Pyramid Star Pattern works

Two star pyramids widen side by side while the space between them shrinks toward the bottom.

01

Build the rows

The outer loop uses ph as the height; the first space loop centers the left pyramid and the middle loop sets the gap.

02

Choose what each row prints

The inc counter grows by two, so both sides gain stars on each row while the central spacing gets smaller.

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.