Right Angle Triangle
Given an integer N, write a program to print a right angle triangle pattern similar to the pattern shown below
/|
/ |
/ |
/ |
/____|
Input
The input will be a single line containing a positive integer (N).Output
The output should be N lines containing the triangle pattern.Explanation
For example, if the given number is 5, the pattern should be printed in 5 lines, as shown below
/|
/ |
/ |
/ |
/____|
Sample Input 1
5
Sample Output 1
/|
/ |
/ |
/ |
/____|
Sample Input 2
4
Sample Output 2
/|
/ |
/ |
/___|
n = int(input())
for i in range(n):
print(' ' * (n - i) + '/', end = '')
if i < n-1:
print(' ' * i, end = '')
else:
print('_' * i, end = '')
print('|')
Comments
Leave a comment