CoreChallenge 18 of 34

Balanced brackets

Write is_balanced(s) that returns True if every opening bracket ( [ { is closed by the matching type in the correct order. Ignore any other characters.

Examples
is_balanced("{[()]}") → True
is_balanced("([)]") → False
Exercise

Balanced brackets

4 checks
def is_balanced(s):
    ...


print(is_balanced("{[()]}"), is_balanced("([)]"))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.