+ 1
How to do balanced parentheses?
I tried this - worked on all the test cases but test 3 which is hidden - thanks in advance def balanced(expression): #your code goes here stack = [] for b in expression: if b == "(": stack.insert(0, b) if b == ")" and len(stack) > 0: stack.pop() return len(stack) == 0 print(balanced(input()))
3 odpowiedzi
0
If for ex: input is ) or
)() return true but it shoud be false
0
Thank you!
0
someone give me the answer please?