Given an integer number N as input. Write a program to print the right-angled triangular pattern of N rows as shown below
For example, if the given number is
5, the output should be
______
| /
| /
| /
| /
| /
for example:
The input is 5. In the first row, we need to print N+1 underscores i.e.,6. After the row with underscores, we need to print the 5 rows. For every row from 2nd row to Nth row i.e; 5 starts with | and ends with /.
can you provide python code for this ?
thanks in advance
N = int(input())
for i in range(N+1):
print('_', end='')
print()
for i in range(N):
print('|', end='')
print(' ' * (N - i - 1), end='')
print('/')
Comments
Leave a comment