Floyd Triangle

Print Floyd triangle pattern.

IntermediatePhase 2 - Level 4: Pattern PrintingExample 10 of 13
floyd-triangle.py
1# Take n
2n = int(input("Enter number of rows: "))
3
4# Print Floyd triangle
5num = 1
6for i in range(1, n + 1):
7 for j in range(1, i + 1):
8 print(num, end=" ")
9 num += 1
10 print()

Output

Enter number of rows: 4
1
2 3
4 5 6
7 8 9 10

What's going on

Print consecutive numbers in rows.

Key Concepts:

Use counter variable
Increment after each print
Different numbers per row