Your question is Parentheses Validation With Nesting. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Parsons configuration text may contain parentheses inside labels, expressions, or annotations. Implement a validator that determines whether every opening parenthesis has a correctly ordered closing parenthesis, allowing arbitrary nesting.
Characters other than ( and ) must be ignored. A string is valid when scanning from left to right never encounters a closing parenthesis without a matching opening parenthesis, and all opening parentheses are closed by the end of the string.
Implement is_valid_parentheses(text), which accepts a string text and returns a Boolean:
True if the parentheses are balanced and correctly nested.False otherwise.( and ).def is_valid_parentheses(text):