Part of the series

Several example codes

~1 min read • Updated Oct 1, 2025

Program Overview

This Python program prints a descending triangle of numbers.
Each row starts from a decreasing number and prints down to 1.
The first row starts at 7 and the last row contains only 1.


Python Code:


# Generate descending triangle
for start in range(7, 0, -1):
    for num in range(start, 0, -1):
        print(num, end=" ")
    print()

Sample Output:


7 6 5 4 3 2 1  
6 5 4 3 2 1  
5 4 3 2 1  
4 3 2 1  
3 2 1  
2 1  
1

Step-by-Step Explanation:

- The outer loop starts from 7 and decreases to 1
- The inner loop prints numbers from the current start value down to 1
- end=" " keeps numbers on the same line
- print() moves to the next row after each line


Written & researched by Dr. Shahin Siami