查找列表中多个项目的索引

6 python string list

我有一份清单

myList = ["what is your name", "Hi, how are you",
          "What about you", "How about a coffee", "How are you"]
Run Code Online (Sandbox Code Playgroud)

现在我想搜索所有出现的"How"和的索引"what".我怎么能用Pythonic方式做到这一点?

Ter*_*ryA 5

听起来单行 Python 就能做到!

[i for i, j in enumerate(myList) if 'how' in j.lower() or 'what' in j.lower()]
Run Code Online (Sandbox Code Playgroud)