# 2019 IUSB Programming Competition # Round 1 Problem 4 # Find out if the open and closed parentheses in a string # are properly matching # Solution by Dana Vrajitoru # Uses Python 3.6.2 #Find out if the parentheses are properly matching def parenthMatch(text): openCount = 0 for c in text: if c == "(": openCount += 1 elif c == ")": if openCount > 0: openCount -= 1 else: return False if openCount == 0: return True else: return False # Testing the function if __name__ == '__main__': print("Enter a string:") str = input() if parenthMatch(str): print("yes") else: print("no")