Is it possible to calculate Hamming Distance as a percentage?

575 Views Asked by At

Hamming Distance is a way to detect text simlarity. However, Hamming Distance only returns an integer. I wonder if it is possible to calculate Hamming Distance out as a percentage. Thanks

My Python code to calculate Hamming Distance

hamming = 0
for i, x in enumerate(FinalString):
    if x != FinalString2[i]:
        hamming += 1
1

There are 1 best solutions below

2
On BEST ANSWER

You can certainly divide the Hamming distance by the length of the string and report the result as a percentage.