1class Solution:2def isValid(self, string: str) -> bool:3while True:4if "()" in string:5string = string.replace("()", "")6elif "{}" in string:7string = string.replace("{}", "")8elif "[]" in string:9string = string.replace("[]", "")1011else:12return not string