len(t) if len(t) == 0: return len(s) cost = 0 if s[-1] == t[-1] else 1 return min(levenshtein(s[:-1], t) + 1, levenshtein(s, t[:-1]) + 1, levenshtein(s[:-1], t[:-1]) + cost) levenshtein("search", “engine”) # 6 levenshtein("Amsterdam", “meetup") # 7 levenshtein("Lplein", “Leidseplein") # 5