Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17854
| References | <th7hs8-one.ln1@chris.zbmc.eu> <roy-AAAEEA.10571424122011@news.panix.com> <roy-BABC0C.11104024122011@news.panix.com> |
|---|---|
| Date | 2011-12-24 17:09 +0000 |
| Subject | Re: How to check for single character change in a string? |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4052.1324746600.27778.python-list@python.org> (permalink) |
On 24 December 2011 16:10, Roy Smith <roy@panix.com> wrote: > In article <roy-AAAEEA.10571424122011@news.panix.com>, > Roy Smith <roy@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, but that's an exercise for the reader :-) Here's a variation on the same theme: sum(map(str.__ne__, str1, str2)) -- Arnaud
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to check for single character change in a string? tinnews@isbd.co.uk - 2011-12-24 15:26 +0000
Re: How to check for single character change in a string? Roy Smith <roy@panix.com> - 2011-12-24 10:57 -0500
Re: How to check for single character change in a string? Roy Smith <roy@panix.com> - 2011-12-24 11:10 -0500
Re: How to check for single character change in a string? Arnaud Delobelle <arnodel@gmail.com> - 2011-12-24 17:09 +0000
Re: How to check for single character change in a string? Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-24 10:22 -0800
Re: How to check for single character change in a string? tinnews@isbd.co.uk - 2011-12-26 22:37 +0000
Re: How to check for single character change in a string? Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-24 08:57 -0700
csiph-web