Brackets Pattern
The program must accept an intager within a pair of brackets as the input The pair of brackam can be any one of the following four types T Parenthes
Square brackets
Curly brackets
Andle bracketbo The program met print the given tractats i Nes back on the following conditions in based on
in the Te only the pair of brachies must be pred the bracks and one part bradat must be printed the inn 3 el 2 inel neted brackets and one pair of brackets must be pr
be
in the aime 4 level 3 st 2 Invel nested bracks and one pair of brackers me Smary the remaining in matbe pred at the outpu
Boundary Condition
Argut Format
The feeling contains within a prof bracket
Output Format
the fine lines contain the bracka pem based on the gen condition
Example Input/Outpu
1000
and H-A and the type of the bran So the parent are pati bet on the given conditions
SOLUTION
PYTHON CODE
s = input().strip()
n = int(s[1:-1])
o,c = s[0],s[-1]
p = [o+c]
for i in range(n):
print(*p[::-1],sep="")
p.append(o+p[-1]+c)
*****************************************************************
Post a Comment