Checking a string against multiple matches

Jerry Hill malaclypse2 at gmail.com
Mon Dec 1 14:51:40 EST 2008


On Mon, Dec 1, 2008 at 2:31 PM, Aaron Scott <aaron.hildebrandt at gmail.com> wrote:
> Pseudocode:
>
> if "two" in ["one", "two", "three", "four"]:
>     return True

That works, just like you wrote it:

>>> "two" in ["one", "two", "three", "four"]
True

>>> "two" in ["one", "twofer", "three", "four"]
False

If that doesn't answer your question, maybe you could give some examples.

-- 
Jerry



More information about the Python-list mailing list