defis_palindrome(self, s): n = len(s) for i in range(n//2 + 1): if s[i] != s[n-1-i]: returnFalse returnTrue
defdfs(self, path, rs, s): if s == "": rs.append(path) return for i in range(1, len(s)+1): if self.is_palindrome(s[:i]): self.dfs(path+[s[:i]], rs, s[i:])