Print Inverted Right Triangle

Print inverted right triangle pattern.

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

Output

Enter number of rows: 5
*****
****
***
**
*

What's going on

Start from n and decrease.

Key Concepts:

Outer loop: n down to 1
Inner loop: print i stars
Decreasing pattern