On Sat, Dec 24, 2011 at 8:26 AM,  <tinn...@isbd.co.uk> wrote:
> 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?
No, but the loop approach is pretty simple:

sum(a == b for a, b in zip(str1, str2))
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to