Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lines_input = int(input())
- open_bracket = 0
- closed_bracket = 0
- flag = False
- for i in range(1, lines_input + 1):
- symbol_input = input()
- if symbol_input == '(' and not flag:
- open_bracket += 1
- flag = True
- elif symbol_input == ')' and flag:
- closed_bracket += 1
- flag = False
- if open_bracket == closed_bracket and open_bracket > 0:
- print('BALANCED')
- else:
- print('UNBALANCED')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement