Solution Review: Balanced Brackets
Review the solution for the "Balanced Brackets" exercise.
We'll cover the following...
Solution
Let’s explore the solution to the problem of balanced brackets.
Press + to interact
def check_balance(brackets):check = 0for bracket in brackets:if bracket == '[':check += 1elif bracket == ']':check -= 1if check < 0:breakreturn check == 0bracket_string = '[[[[]]'print(check_balance(bracket_string))
...