Given an integer number
N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.Note: There is a space after each asterisk (*) character.
In the given example the hollow right angled triangle of side
4. Therefore, the output should be
*
* *
* *
* * * *
5.Therefore, the output should be
*
* *
* *
* *
* * * * *
N = int(input())
first_line = '*'.rjust(N * 2 - 1, ' ')
last_line = ('* ' * (N - 1) + '*').rjust(N, ' ')
triangle = first_line
for line in range(N - 2):
triangle += '\n' + ('* ' + (' ' * line * 2) + '*').rjust(N * 2 - 1, ' ')
triangle += '\n' + last_line
print(triangle)
Comments
Leave a comment