Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string_of_symbols = input()
- list_of_symbols = []
- copy_of_list = []
- i = 0
- k = 0
- letters = ["a-z","A-Z",0-9]
- for symbol in string_of_symbols:
- i += 1
- k += 1
- if string_of_symbols[0] != "[" and string_of_symbols[0] != "(" and string_of_symbols[0] != "{" and not symbol in letters or len(string_of_symbols) == 1:
- print("1")
- break
- elif symbol == "[" or symbol == "(" or symbol == "{":
- list_of_symbols.append(symbol)
- copy_of_list.append(symbol)
- else:
- if len(list_of_symbols) !=0:
- if (symbol == "]" and list_of_symbols[-1] != "[") or (symbol == "}" and list_of_symbols[-1] != "{") or (symbol == ")" and list_of_symbols[-1] != "(") and symbol not in letters:
- print(i)
- break
- else:
- list_of_symbols.pop()
- k -= 1
- if len(list_of_symbols) == 0 and i == len(string_of_symbols):
- print("Success")
- elif i == len(string_of_symbols) and len(list_of_symbols) > 0:
- print(k)
- else:
- print(i)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement