Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. print('Input string:')
  2. string=input()
  3.  
  4. def cout_symb(string,char):
  5. i=0
  6. count=0
  7. if len(string) == 0:
  8. return(0)
  9. while i<len(string):
  10. if string[i]==char:
  11. count += 1
  12. i += 1
  13. return(count)
  14.  
  15. def Solution(S):
  16. i = 0
  17. while i<=len(S):
  18. left_part=S[0:i]
  19. rigth_part=S[i:]
  20. count_opening=cout_symb(left_part,'(')
  21. count_closing=cout_symb(rigth_part,')')
  22. if count_opening == count_closing:
  23. return(i)
  24. i += 1
  25.  
  26. print(Solution(string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement