[triangle-zpug] how to match strings in python
chris at archimedeanco.com
Thu Apr 2 20:11:02 UTC 2009
On Thu, Apr 2, 2009 at 3:27 PM, Chris Calloway <cbc at unc.edu> wrote:
> On 4/2/2009 2:15 PM, Jay Lyerly wrote:
>> For the python golfers.....
>> for (x,y) in zip(a,b): m+= x * (x==y)
>> m contains the matching substring. That's as close to one line as I could
>> get. :)
> Here it is in one line (synthesizing Jay and Chris Rossi's solution with a
> list comprehension:
> >>> "".join([(x*(x==y)) for (x,y) in zip('foobar','foobaz')])
The Other Chris
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the triangle-zpug