How do I get the probability of a string being similar to another string in Python?
I want to get a decimal value like 0.9 (meaning 90%) etc. Preferably with standar
You can create a function like:
def similar(w1, w2): w1 = w1 + ' ' * (len(w2) - len(w1)) w2 = w2 + ' ' * (len(w1) - len(w2)) return sum(1 if i == j else 0 for i, j in zip(w1, w2)) / float(len(w1))