Roy Smith r...@panix.com wrote:
In article roy-aaaeea.10571424122...@news.panix.com,
Roy Smith r...@panix.com wrote:
len([x for x in zip(s1, s2) if x[0] != x[1]])
Heh, Ian Kelly's version:
sum(a == b for a, b in zip(str1, str2))
is cleaner than mine. Except that Ian's counts
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
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
In article th7hs8-one@chris.zbmc.eu, tinn...@isbd.co.uk wrote:
Can anyone suggest a simple/easy way to count how many characters have
changed in a string?
Depending on exactly how you define changed, you're probably talking
about either Hamming Distance or Levenshtein Distance. I would
In article roy-aaaeea.10571424122...@news.panix.com,
Roy Smith r...@panix.com wrote:
len([x for x in zip(s1, s2) if x[0] != x[1]])
Heh, Ian Kelly's version:
sum(a == b for a, b in zip(str1, str2))
is cleaner than mine. Except that Ian's counts matches and the OP asked
for non-matches,
On 24 December 2011 16:10, Roy Smith r...@panix.com wrote:
In article roy-aaaeea.10571424122...@news.panix.com,
Roy Smith r...@panix.com wrote:
len([x for x in zip(s1, s2) if x[0] != x[1]])
Heh, Ian Kelly's version:
sum(a == b for a, b in zip(str1, str2))
is cleaner than mine. Except
On Dec 24, 11:09 am, Arnaud Delobelle arno...@gmail.com wrote:
sum(map(str.__ne__, str1, str2))
Mirror, mirror, on the wall. Who's the cleanest of them all?
--
http://mail.python.org/mailman/listinfo/python-list