Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; ':-)': 0.06; 'subject:string': 0.09; 'received:209.85.214.174': 0.13; 'roy': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'cc:no real name:2**0': 0.20; 'asked': 0.22; 'header:In-Reply- To:1': 0.22; 'cc:2**0': 0.24; 'subject:change': 0.24; 'exercise': 0.28; 'message-id:@mail.gmail.com': 0.28; 'matches': 0.29; 'cc:addr:python.org': 0.29; 'subject:?': 0.31; 'received:209.85.214': 0.32; 'subject:How': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'version:': 0.39; 'received:209': 0.40; '2011': 0.61; 'article': 0.74; 'variation': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=XHtleCO/SCM1Qm3YAETr+WrfCNI+WYKRNRsss5SG+ig=; b=YQAAfdF+RqckXUX2tRQkOvUqBadDBeM3ltU0FJtP4k7ZH8CcekWrxXOGR6FrB8L2VU UHTLxhG1+x+G3mhM8bwgU7bZNSup/p2Jmcz1AgLipYcXNojEgF5yBiNyseqUFTBZgAuQ iG5mEt2e0tI/POiVRj/BCGEHEPQBDCkau0jUw= MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 24 Dec 2011 17:09:57 +0000 Subject: Re: How to check for single character change in a string? From: Arnaud Delobelle To: Roy Smith Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324746600 news.xs4all.nl 6840 [2001:888:2000:d::a6]:60470 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17854 On 24 December 2011 16:10, Roy Smith wrote: > In article , > =C2=A0Roy Smith wrote: > >> >>> len([x for x in zip(s1, s2) if x[0] !=3D x[1]]) > > Heh, Ian Kelly's version: > >> sum(a =3D=3D b for a, b in zip(str1, str2)) > > is cleaner than mine. =C2=A0Except that Ian's counts matches and the OP a= sked > 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)) --=20 Arnaud