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('Please enter a positive integer: '))
for i in range(n-1):
print(' '*(n-1-i),'/',' '*i,'|',sep ='')
# last line print
print('/','_'*(n-1),'|',sep ='')
Comments
Very helpful, thank you
Leave a comment