We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 05b887d + c930aaa commit 9e996a0Copy full SHA for 9e996a0
Python/parenthesisBalancing.py
@@ -0,0 +1,32 @@
1
+
2
+#stack is used to make parenthesis balancing checker
3
4
5
+def checker(inp):
6
+ stre=''
7
+ pairs={}
8
+ pairs[')']='('
9
+ pairs['}']='{'
10
+ pairs[']']='['
11
+ stack=[]
12
+ for i in list(inp):
13
+ if i==']' and i=='}' and i==')':
14
+ len(stack)==0 or stack.pop() != pairs[i] ? return False:pass
15
+ else :
16
+ stack.push(i)
17
+ return True
18
19
20
21
22
23
24
25
26
+def main():
27
+ inp=str(input("Enter the word:"))
28
+ print ( "balanced" if checker(inp) else "un-balanced")
29
30
31
32
+main()
0 commit comments