Python Program to Print (Generate) Right Angle Triangle Star Pattern
This python program generates right angle triangle pattern of stars up to n lines.
In this python example, we first read number of row in the right angle triangle pattern from user using built-in function input()
. Since function input()
returns string value, we need to convert given number to number type using int()
. And then we generate right angle triangle pattern using python's loops
Python Source Code: Right Angle Triangle Pattern
# Generating Right Angle Triangle Pattern Using Stars
row = int(input('Enter number of rows required: '))
for i in range(row):
for j in range(i+1):
print('*',end=' ')
print()
In this program print()
only is used to bring control to new lines.
Output
Enter number of rows required: 9 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *