Hollow Right Triangle Star Pattern Python Program #youtubeshorts

Posted by

Hollow Right Triangle Star Pattern

Python Program to Print Hollow Right Triangle Star Pattern

This program will print a hollow right triangle star pattern based on the user’s input.

        
            def hollow_right_triangle(rows):
                for i in range(0, rows):
                    for j in range(0, i + 1):
                        if j == 0 or j == i or i == rows - 1:
                            print("*", end="")
                        else:
                            print(" ", end="")
                    print()
                

            rows = int(input("Enter the number of rows: "))
            hollow_right_triangle(rows)
        
    

Copy and paste the above code into a Python editor and run the program to see the hollow right triangle star pattern based on your input.

Try changing the number of rows to see different patterns!