Your question is Brace Matching Coding. 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.
PagerDuty Event Orchestration expressions may contain parentheses, square brackets, and curly braces. Given an expression string, determine whether every bracket is properly closed and correctly nested.
A string is valid when:
Return True if the expression is valid. Otherwise, return False.
Implement is_valid_brackets(expression), which accepts a string and returns a Boolean. The input contains printable ASCII characters. An empty string is valid because it contains no unmatched brackets.
def is_valid_brackets(expression):