Python Program to Print Consecutive Rows Numbers in Right Triangle

Write a Python program to print consecutive rows numbers in right triangle pattern using for loop.

rows = int(input("Enter Consecutive Numbers in Right Triangle Pattern Rows = "))

print("====Consecutive Row Numbers Right Triangle Pattern====")

for i in range(1, rows + 1):
    val = i
    for j in range(1, i + 1):
        print(val, end = ' ')
        val = val + rows - j
    print()
Python Program to Print Consecutive Rows Numbers in Right Triangle

This Python example prints the right angled triangle pattern of consecutive row numbers using a while loop.

rows = int(input("Enter Consecutive Numbers in Right Triangle Pattern Rows = "))

print("====Consecutive Row Numbers Right Triangle Pattern====")

i = 1

while(i <= rows):
    val = i
    j = 1
    while(j <= i):
        print(val, end = ' ')
        val = val + rows - j
        j = j + 1
    print()
    i = i + 1
Enter Consecutive Numbers in Right Triangle Pattern Rows = 12
====Consecutive Row Numbers Right Triangle Pattern====
1 
2 13 
3 14 24 
4 15 25 34 
5 16 26 35 43 
6 17 27 36 44 51 
7 18 28 37 45 52 58 
8 19 29 38 46 53 59 64 
9 20 30 39 47 54 60 65 69 
10 21 31 40 48 55 61 66 70 73 
11 22 32 41 49 56 62 67 71 74 76 
12 23 33 42 50 57 63 68 72 75 77 78 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.