0

Hey guys can someone please tell me wat wrong with my code for the balanced paranthesis challenge

https://code.sololearn.com/c5SquL6644XN/?ref=app

1st Feb 2022, 8:06 AM
Mkhuliseni Sithole
3 ответов
+ 3
Mkhuliseni Sithole What if )) (( This is not balanced. For balanced should be like this: (())
1st Feb 2022, 8:41 AM
A͢J
A͢J - avatar
+ 2
Mkhuliseni Sithole Whilst I agree with A͢J , I believe your problem is not that complex allowing for the level of difficulty of the challenge. Your responses are phrased as Strings, I believe the responses need to be boolean, so try this adaptation to your code. open_list= ["{","(","["] close_list= ["}",")","]"] def balanced(expression): #your code goes here stack1= [] stack2= [] for i in expression: if i in open_list: stack1.append(i) elif i in close_list : stack2.append(i) return len(stack1) == len(stack2 ) expression = input() print(balanced (expression ))
1st Feb 2022, 8:51 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Okay thank you guys always helpful🙏🏿🙏🏿
1st Feb 2022, 8:55 AM
Mkhuliseni Sithole