Guest User

Untitled

a guest
Apr 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. def pair_balance(parentheses):
  2. missing_pairs = 0
  3. for parenthesis in parentheses:
  4. if parenthesis == '(':
  5. missing_pairs += 1
  6. elif parenthesis == ')':
  7. if missing_pairs == 0:
  8. return False
  9.  
  10. missing_pairs -= 1
  11.  
  12. return True if missing_pairs == 0 else False
Add Comment
Please, Sign In to add comment