Stacks and queues · routine
Balanced brackets
Write balanced(text): True if every (, [ and { is closed by the right bracket in the right order. Other characters are ignored.
"([]{})" is balanced; "([)]" is not.
- right answers
- arguments left as they should be
Run adds print(balanced("([)]")) after your code, to try it.
Stuck on the idea rather than the code? The Stacks and queues lesson walks through it.