asking

alex23 wuwei23 at gmail.com
Wed Aug 22 01:51:04 EDT 2012


On 22/08/12 03:57, mingqiang hu wrote:
> can I use just one statement to figure out if substring “a” ,"b" "c"
> are in string "adfbdfc" ? not use the statement like
> ("a" in "adfbdfc") or ( "b" in "adfbdfc") or ("c" in "adfbdfc" )
> ,because if I have lots of substring, this could sucks

subs = ['a', 'b', 'c']
string = 'abcdef'

def all_in(string, substrings):
    return all(map(string.__contains__, subs))



More information about the Python-list mailing list