The third test case of "Balanced Parentheses" which is 100XP in python is hidden and it doesn't give clue attaching my ans below | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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()))

6th May 2022, 6:15 AM
Ratnesh N. Singh
Ratnesh N. Singh - avatar
2 Answers
+ 2
())
6th May 2022, 7:06 AM
Oma Falk
Oma Falk - avatar
+ 2
Ratnesh N. Singh There is one more condition after second if condition inside loop elif i == ")" and len(l1) == 0: return False
6th May 2022, 7:06 AM
A͢J
A͢J - avatar