Jul-21-2017, 09:01 PM
(Jul-21-2017, 01:32 PM)DeaD_EyE Wrote: If you want to check if any of the names is in the string, you can write it more compact:
any(name in s for name in ('Bob', 'Ed'))
Wonderful. I knew I could use a loop but was looking for something more compact. However, I don't see the need for "any." The following seems to work:
(name in s for name in ('Bob', 'Ed'))Is there an advantage to using "any" I'm not seeing. I understand using "all" if that's required.