Checking a string against multiple matches

Aaron Scott aaron.hildebrandt at
Mon Dec 1 20:31:03 CET 2008

I've been trying to read up on this, but I'm not sure what the
simplest way to do it is.

I have a list of string. I'd like to check to see if any of the
strings in that list matches another string.


if "two" in ["one", "two", "three", "four"]:
     return True

Is there any built-in iteration that would do such a thing, or do I
have to write a function to check for me? I was using .index on the
list, but it would return True for strings that contained the search
string rather than match it exactly, leading to false positives in my

More information about the Python-list mailing list