0
elif any(s in (title or desc) for s in ('men', 'why')):

I am trying to write a code where if there is Men, mEn, meN, Why, wHy, whY in either title or desc it should return false. so essentially, men and why are capitalization neutral. :(

This is really hard!

  • 1
    Lowercase each input to be examined before comparing against lowercase string literals `men` and `why`. – Tim Biegeleisen Jan 27 '22 at 05:36
  • 2
    @TimBiegeleisen. Or casefold it, although the issue is with the `or` – Mad Physicist Jan 27 '22 at 05:39
  • `s in title or s in desc`. That's just how the operator works. `(title or desc)` is `title` if its Truthy, otherwise `desc`, which is not quite what you want. – Mad Physicist Jan 27 '22 at 05:42
  • More like `any(word.casefold() in ('men', 'why') for word in title.split() + desc.split())` - I feel the question was closed prematurely, although it's really not all that hard... – Grismar Jan 27 '22 at 05:43

0 Answers0