Balanced Brackets
Medium · Algorithms
A stack is a list where you only append to the end and pop from the end. It is perfect for brackets: push every opening bracket, and when you meet a closing bracket, the top of the stack must be its matching opener.
Write is_balanced(text) that returns True if every (, [ and { is closed by the matching bracket in the right order, and False otherwise. Ignore all other characters. An empty string is balanced.