Error while submitting code

In the question where we need to generate parenthesis, the code I wrote is working on jupyter-notebook. Also, it showing success when I run the code but when I submit it, it says wrong answer for all the test cases. I can’t seem to find the error.

Code:
def genParenthesis(openB, closeB, n, l=[]):

if(closeB == n):
    print(''.join(l))

else:
    if(openB>closeB):
        l.append(')')
        genParenthesis(openB, closeB+1, n, l)
        l.pop()

    if(openB<n):
        l.append('(')
        genParenthesis(openB+1, closeB, n, l)
        l.pop()

return

n = int(input())
if n>=1 & n<=11:
genParenthesis(0, 0, n)

Can you please share the link of the question?

Thanks

https://online.codingblocks.com/player/23939/content/6766/5144

Hi @Sasha-Makkar-948226205325440,

Your code is perfectly correct (except for that if statement) and I got all the test cases passed.
There is no need to explicitly check the authenticity of the input until specified. It is already given in the question that n >= 1 and n <=11, hence there will be no inputs that will say otherwise.
(btw, thanks for the points :wink: )

Happy Learning :slight_smile:

Thanks! It worked this time with the same code though i dont know how :sweat_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.