3 ms·
You can also avoid building the list and terminate at the first true value with `any`: free_food = any(s for s in soup.stripped_strings if ...)
by js2 10y ago
You can also avoid building the list and terminate at the first true value with `any`:
free_food = any(s for s in soup.stripped_strings if ...)
- tedmiston 10y agoWell on that note, if you just want the boolean, I think it'd be enough to say: free_food = 'free' in soup.get_text().lower()