~1 min read • Updated Oct 6, 2025
Program Overview
This Python program reads an integer n between 1 and 80 and prints a left-aligned triangle using asterisks (*).
Each row contains one more asterisk than the previous row, forming a simple increasing triangle.
Python Code:
# Read n from user
n = int(input("Enter a number between 1 and 80: "))
# Validate input
if 1 <= n <= 80:
for i in range(1, n + 1):
print('*' * i)
else:
print("The number must be between 1 and 80.")
Sample Output for n = 5:
*
**
***
****
*****
Step-by-Step Explanation:
- The user inputs a number n
- The program checks that n is between 1 and 80
- A loop runs from 1 to n, printing i asterisks on each line
- The result is a left-aligned triangle that grows line by line
Written & researched by Dr. Shahin Siami