Free lab Real Python 3. Zero installs. Your code stays in this browser. Open the playground

Balanced Brackets

Medium · 55 XP

Write is_balanced(s) returning True when every bracket ()[]{} is closed in the right order. Print the result for four test strings.

Target output
{[()]} True
{[(])} False
((())) True
(] False
Blank · autosaved
PYbalanced-brackets.py
Run your code to check it…
Your next ten minutes

Write Python that does something useful.

Start free. No install, no card, no passive video marathon.

Start learning free → Explore the path