Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
The third test case of "Balanced Parentheses" which is 100XP in python is hidden and it doesn't give clue attaching my ans below
def balanced(expression): #your code goes here l1=[] for i in expression: if i == '(': l1.insert(0,'(') if i == ')' and len(l1)>0: l1.pop(0) if len(l1) == 0: return True else: return False print(balanced(input()))
2 ответов
+ 2
())
+ 2
Ratnesh N. Singh
There is one more condition after second if condition inside loop
elif i == ")" and len(l1) == 0:
return False