Print Number Pattern
Print a basic right-angled triangle number pattern using nested loops.
BeginnerTopic: Loop Programs
Python Print Number Pattern Program
This program helps you to learn the fundamental structure and syntax of Python programming.
# Program to print a right-angled number triangle
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()Output
Enter number of rows: 4 1 1 2 1 2 3 1 2 3 4
Understanding Print Number Pattern
We use nested loops: the outer loop controls rows and the inner loop prints numbers from 1 up to the row index.
Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.