Part of the series

Several example codes

~1 min read • Updated Oct 7, 2025

Program Overview

This Python program reads the number of rows from the user and generates a structured output based on that count.
In this example, the output is a numeric triangle, but you can customize it to display stars, letters, or any other pattern.


Python Code (Simple Numeric Pattern):


rows = int(input("Enter number of rows: "))

for i in range(1, rows + 1):
    for j in range(1, i + 1):
        print(j, end=" ")
    print()

Sample Output for 4 Rows:


1  
1 2  
1 2 3  
1 2 3 4

Step-by-Step Explanation:

- The user inputs the number of rows
- A nested loop prints numbers from 1 up to the current row index
- Each row is printed on a new line
- You can easily modify this to generate other patterns like Pascal’s triangle, binary sequences, or ASCII art


Written & researched by Dr. Shahin Siami