1def isBalanced(final_str):
2 type_brackets = ['()', '{}', '[]']
3 while any(x in final_str for x in type_brackets):
4 for br in type_brackets:
5 final_str = final_str.replace(br, '')
6 return not final_str
7
8
9string = "{[]{()}}"
10print(string, "-", "Balanced"
11 if isBalanced(string) else "Unbalanced")
12