human
Solve in Python:
You are given a string s containing lowercase letters and an integer k. You need to :

First, change some characters of s to other lowercase English letters.
Then divide s into k non-empty disjoint substrings such that each substring is palindrome.

Return the minimal number of characters that you need to change to divide the string.
 
Example 1:
Input: s = "abc", k = 2
Output: 1
Explanation: You can split the string into "ab" and "c", and change 1 character in "ab" to make it palindrome.

Example 2:
Input: s = "aabbc", k = 3
Output: 0
Explanation: You can split the string into "aa", "bb" and "c", all of them are palindrome.
Example 3:
Input: s = "leetcode", k = 8
Output: 0

 
Constraints:

1 <= k <= s.length <= 100.
s only contains lowercase English letters.

=====
Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

class Solution:
    def palindromePartition(self, s: str, k: int) -> int:
        self.memo = {}
        return self.dfs(s, k)
    
    def dfs(self, s, k):
        if (s, k) not in self.memo:
            res = float('inf')
            if len(s) == k:
                res = 0
            elif k == 1:
                res = sum(s[i] != s[-1-i] for i in range(len(s)//2))
            else:
                for i in range(1, len(s) - k + 2):
                    res = min(self.dfs(s[:i], 1) + self.dfs(s[i:], k - 1), res)
            self.memo[s, k] = res
        return self.memo[s, k]