我怎样才能让这段代码不使用列表或大量的条件语句?

How can I make this code not use a list or a ton of conditional statements?

我正在制作一个 AI,我希望它能够搜索东西。不过我不知道如何有效地做到这一点。

再次编辑:我自己修复了。

而不是将第二个单词放入包含输出中每个单词的列表中,并将其添加到搜索查询中。我获取了输出并从中删除了第一个词(即“查找”或“搜索”),然后它将其添加到搜索查询中。感谢大家的帮助。

如果这真的是您想要的:

words = output.split(' ', 1)
if words[0] == 'search' and words[1] in Terms:
    print("win")

对于初学者,您可以忘记那么长的 if 条件,然后试试这个:

Terms = ['music','gaming','Minecraft','dank desmondo']
output = "search music"
if output.split()[1] in Terms:
    print(True)
else:
    print(False)