from Levenshtein import distance def string_match(result, orig): lev = distance(result, orig) return (1 - (lev / max(len(result), len(orig))) * 100)