Python Inverted Right-Offset Star Triangle (Pattern 29)

Python Code
for x in range(5, 0, -1):
    for y in range(x, 5):
        print(" ", end="")
    for z in range(0, x):
        print("*", end="")
    print()

# Another Logic

for x in range(5, 0, -1):
    for y in range(5, 0, -1):
        if x >= y:
            print("*", end="")
        else:
            print(" ", end="")
    print()

Output:

Output of the Python Inverted Right-Offset Star Triangle pattern
BEGINNER WALKTHROUGH

How the Inverted Right-Offset Star Triangle works

Five stars begin at the left, and each following row is shorter and shifted farther right.

01

Build the rows

The outer loop counts down from 5 to 1. Its companion loop adds one more leading space as the row shrinks.

02

Choose what each row prints

The star loop runs x times, so the visible row lengths decrease from five to one.

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.