0
4th project of python course of data structure
I have problem in test case 3 and 7 . Can anyone solve it i put my code in comments def balanced(expression): #your code goes here list=[] for i in expression : if i=="(": list.insert(0,i) elif i==")": list.pop(0) if list==[] : return True else: return False print(balanced(input()))
3 Réponses
0
What happens if the input is like this:
( ) ) (.
Does your code say true or false. Mine says false.
My code has a check that the number of ) is never larger as the number of (. If it happens i return false.
0
It return false
0
And this: ( ( ) ) ) ( ( ).