Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pars = {")": "(", "]": "["}
- def par_checker_mod(string):
- stack = []
- for s in string:
- if s in "([":
- stack.append(s)
- elif s in ")]":
- if len(stack) > 0:
- if stack[-1]== pars[s]:
- stack.pop()
- else:
- return False
- else:
- return False
- return len(stack)==0
- # par_checker_mod(')({{)(}}}')
- par_checker_mod('(5+6)*(7+8)/(4+3)')
- print(par_checker_mod('(5+6)*(7+8)/(4+3)'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement