Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print('Input string:')
- string=input()
- def cout_symb(string,char):
- i=0
- count=0
- if len(string) == 0:
- return(0)
- while i<len(string):
- if string[i]==char:
- count += 1
- i += 1
- return(count)
- def Solution(S):
- i = 0
- while i<=len(S):
- left_part=S[0:i]
- rigth_part=S[i:]
- count_opening=cout_symb(left_part,'(')
- count_closing=cout_symb(rigth_part,')')
- if count_opening == count_closing:
- return(i)
- i += 1
- print(Solution(string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement