Can you please tell me what's wrong with this code, it's giving wrong answer when I am submitting it, but giving correct when I am testing it

n = int(input())

def printParathesis(n,cB,oB,opSoFar):
if cB==n:
print(opSoFar)
opSoFar=’’
return
if oB<n:
printParathesis(n,cB,oB+1,opSoFar+’(’)
if cB<oB:
printParathesis(n,cB+1,oB,opSoFar+’)’)

printParathesis(n,0,0,’’)

hey @Mohit2000 ,
Your output is reverse order.
Your current output is
((()))
(()())
(())()
()(())
()()()

Whereas it needs to be
()()()
()(())
(())()
(()())
((()))

Just change your logic to reverse it.