python beginner Termina em 2026-11-17

Balanced brackets

Write is_balanced(text) that returns True when every (, [ and { in the text is closed by the matching bracket in the right order.

  • Other characters are ignored, so "print(items[0])" is balanced.
  • "(]" and "(()" are not.

Acceptance criteria

  • An empty string is balanced.
  • The tests at the bottom print All tests passed.

Hint: a stack (a Python list) is all you need.

Resolvido por 0 pessoas até agora.

python
EditorCtrl + Enter

            
        

Quando os testes mostram "All tests passed", o desafio fica marcado como resolvido neste navegador.

Envie sua solução para revisão