Print an n level reverse pyramid as follows where n is a positive integer taken as input. each triangle will be made out of “*”

Print an n level reverse pyramid as follows where n is a positive integer taken as input. each triangle will be made out of “*” symbols and the spaces will be filled by "#" symbols for each row. for example, a 3 level reverse pyramid will look as follows:

*****
#***#
##*##

Note: There should be no space between the stars. Remember to not print any extra character or spaces or else your solution could be rejected.

Sample input: 4

Sample output:

*******
#*****#
##***##
###*###

Reverse triangle Python

n=int(input())
i=n-1
while i>-1:
        print('#'*(n-i-1) + '*'*(2*i+1)+'#'*(n-i-1))
        i=i-1

Comments