A triangle is said to be right-angled if it has an angle equal to 90 degrees on its left side.
We will use 2 for loops:
# Number of rows
n = 5
# Loop through rows
for i in range(1, n+1):
# Loop through columns
for j in range(1, n+1):
# Printing Pattern
if (i == j) or (j == 1) or (i == n):
print("*", end=" ")
else:
print(" ", end=" ")
print()
Output:
*
* *
* *
* *
* * * * *
Comments
Leave a comment