I mean any of "a","b","c" in string "adfbdfc"  makes the statement true,can I not use a function?  suppose I got lots of substring let's say s1="a",s2="b",s3="c" ...,not wrap them as a tuple or a list , just make the statement as simple as possible to check if any of the value is the substring of S="fasfasdfgbefve".<br>
<br><div class="gmail_quote">On Wed, Aug 22, 2012 at 1:17 PM, Dave Angel <span dir="ltr"><<a href="mailto:d@davea.name" target="_blank">d@davea.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 08/22/2012 12:17 AM, Ian Foote wrote:<br>
> Oops, hopefully this with indent correctly:<br>
><br>
> def all_in(string, substrings):<br>
>     for substring in substrings:<br>
>         if substring not in string:<br>
>             return False<br>
>     return True<br>
<br>
The POP's question was ambiguous (did he want to match any of the<br>
substrings, or all of the substrings), but his example code:<br>
<div class="im"><br>
<br>
("a" in "adfbdfc")  or ( "b" in "adfbdfc") or ("c" in "adfbdfc" )<br>
<br>
</div>implements the opposite sense of what you have.  So perhaps he'd want:<br>
<br>
<br>
def any_in(string, substrings):<br>
    for substring in substrings:<br>
        if substring in string:<br>
              return True:<br>
    return False<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<br>
DaveA<br>
<br>
</font></span></blockquote></div><br>