Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17853

Re: How to check for single character change in a string?

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: How to check for single character change in a string?
Date 2011-12-24 11:10 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-BABC0C.11104024122011@news.panix.com> (permalink)
References <th7hs8-one.ln1@chris.zbmc.eu> <roy-AAAEEA.10571424122011@news.panix.com>

Show all headers | View raw


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 :-)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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