+ 1
Why the code das not work for one case
I wrote code for a challenge in the data structures course and the code works good for all the cases except one. This is the code: def balanced(expression): #your code goes here open = 0 close = 0 expression = list(expression ) for c in expression: if c == "(": open += 1 elif c == ")": close += 1 if close == open : return True else : return False print(balanced(input())) (I need to find duplicate parentheses)
3 Respuestas