manstey wrote:
> Hi,
>
> Is there a clever way to see if two strings of the same length vary by
> only one character, and what the character is in both strings.
>
> E.g. str1=yaqtil str2=yaqtel
>
> they differ at str1[4] and the difference is ('i','e')

something like this maybe?

>>> str1='yaqtil'
>>> str2='yaqtel'
>>> set(enumerate(str1)) ^ set(enumerate(str2))
set([(4, 'e'), (4, 'i')])
>>>

-- 
- Justin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to