In this program, we will construct the pattern using a nested for loop.
Steps to solve the program
- Use for loop with range function to iterate over numbers from 1-5.
- Initiate another for loop inside the above for loop to print the number initiated by 1st for lopp times the given in the pattern.
- Print the output.
for i in range(1,6):
for j in range(i):
print(i,end=" ")
print()
Output :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5