top of page

Python program to print left and right angle triangle

  1. Left Angle Triangle Pattern








The python code will be:

n=int(input("Enter the no of rows: "))
for i in range(0,n+1):
    for j in range(0,i):
        print("*",end=' ')
The output will be:

Logic: So in this first of all we are taking input for printing the pattern from the user (till how many rows the user wants to print). After that, we first initialize a loop for our rows from 0 to n+1 and then initialize a second loop for our columns from 0 to I, and in the column loop, we print the star.

So in this way, our program will print the pattern

2. Right Angle Triangle: