This Python program reads an integer n between 1 and 8 and prints a left-aligned triangle using asterisks (*) with spaces between them.
Each row contains one more asterisk than the previous, forming a simple spaced triangle.
# Read n from user
n = int(input("Enter a number between 1 and 8: "))
# Validate input
if 1 <= n <= 8:
for i in range(1, n + 1):
print('* ' * i)
else:
print("The number must be between 1 and 8.")
*
* *
* * *
* * * *
* * * * *
- The user inputs a number n
- The program checks that n is between 1 and 8
- A loop runs from 1 to n, printing i asterisks separated by spaces on each line
- The result is a left-aligned triangle with clean spacing between stars