jazbees <jazb...@gmail.com> wrote: >>>> hasvowels = lambda x:max([y in x for y in "aeiou"]) >>>> hasvowels("parsnips") > True >>>> hasvowels("sfwdkj") > False >
Do you object to using def to define functions? Anyway, it is probably clearer to use the builtin 'any' for code like this: >>> def hasvowels(s): ... return any(v in s for v in "aeiou") ... >>> hasvowels("parsnips") True >>> hasvowels("sfwdkj") False >>> >>>> foo = ["green", "orange"] >>>> bar = ["blue", "green", "red", "yellow"] >>>> found = lambda x,y:max([z in y for z in x] if x else [False]) >>>> found(foo, bar) > True >>>> foo = [] >>>> found(foo, bar) > False If you are doing a lot of this consider whether you might be better off using sets: >>> def found(x,y): ... return bool(set(x).intersection(y)) ... -- http://mail.python.org/mailman/listinfo/python-list