First different char in two strings?
emile at fenx.com
emile at fenx.com
Mon May 22 20:14:08 EDT 2000
Hang on, I'm sure you'll get a faster method than this! ;-)
But, being as I generally find that the obvious way is often the
fastest,
or close enough, here's the obvious:
a = "this is a test"
b = "this is not a test"
for i in range(len(a)):
if b[i] != a[i]:
break
print i
It-all-depends-on-the-strings-you-expect-ly y'rs,
Emile van Sebille
emile at fenx.com
Stefan Franke <spamfranke at bigfoot.de> wrote in message
news:<392abd40.10218183 at news.btx.dtag.de>...
> What's the fastest way to find the first different character inside two strings?
>
> Stefan
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list