Example 1 — Shrink the row with range
The step -1 counts down. The inner loop still starts at 1 and stops after row.
rows = 5
for row in range(rows, 0, -1):
for n in range(1, row + 1):
print(n, end="")
print() How It Works
range(rows, 0, -1)yields 5, 4, 3, 2, 1. It never yields 0.- The inner
rangealways restarts at 1, so every row begins with 1. end=""keeps the digits together.print()starts the next row.

