Given an integer number N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.
The first line of input is a positive integer.
For example, if the given number is
5, the output should be
______
| /
| /
| /
| /
|/
7,the out put should be
________
| /
| /
| /
| /
| /
| /
|/
n = int(input('Please enter a positive integer: '))
for i in range(n):
print("_", end='')
print()
for i in range(n+1):
for j in range(n-i):
if(j == 0):
print("|",end='')
if(j == n-i-1):
print("/", end='')
else:
print(" ", end='')
print()
Comments
Leave a comment