Part of the series

Several example codes

~2 min read • Updated Oct 6, 2025

Program Overview

This Python program reads an integer n between 1 and 8 and prints a two-part pattern:
1. An increasing triangle made of checkmarks ()
2. A decreasing sequence of horizontal lines made of asterisks (*)
The first part always prints 3 rows of checkmarks. The second part prints lines of stars starting from n down to 1.


Python Code:


# Read n from user
n = int(input("Enter a number between 1 and 8: "))

# Validate input
if 1 <= n <= 8:
    # Part 1: Checkmark triangle
    for i in range(1, 4):
        print('✓' * i)

    # Part 2: Decreasing star lines
    for i in range(n, 0, -2):
        print('*' * i)
else:
    print("The number must be between 1 and 8.")

Sample Output for n = 7:


✓  
✓✓  
✓✓✓  
*******  
*****  
***  
*

Step-by-Step Explanation:

- The user inputs a number n
- The first loop prints 3 rows of checkmarks, increasing by one per row
- The second loop prints horizontal lines of stars, decreasing from n to 1 in steps of 2
- This creates a visually balanced pattern combining symbols and structure


Written & researched by Dr. Shahin Siami