How to check for single character change in a string?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Sat Dec 24 10:26:21 EST 2011


Can anyone suggest a simple/easy way to count how many characters have
changed in a string?

E.g. giving results as follows:-

    abcdefg     abcdefh         1
    abcdefg     abcdekk         2
    abcdefg     gfedcba         6


Note that position is significant, a character in a different position
should not count as a match.

Is there any simpler/neater way than just a for loop running through
both strings and counting non-matching characters?

-- 
Chris Green



More information about the Python-list mailing list