Dremendo Tag Line

Print mirrored right triangle star pattern using for loop in Python

for Loop - Question 17

In this question, we will see how to print the mirrored right triangle star pattern in Python programming using for loop. To know more about for loop click on the for loop lesson.

Q17) Write a program in Python to print the mirrored right triangle star pattern using for loop.

    *
   **
  ***
 ****
*****

Program

for r in range(1,6):

    # printing the space
    for c in range(4,r-1,-1):
        print(' ',end='')

    # printing the star
    for c in range(0,r):
        print('*',end='')

    print()
    

Output

    *
   **
  ***
 ****
*****
video-poster