打印字符串中关键字的答案(python 2.7)

时间:2016-10-27 11:43:03

标签: python string python-2.7

所以我正在尝试制作这样的代码片段,用户将被问到他们的设备有什么问题,并且根据他们的输入,代码将识别此字符串中的“关键字”,因此打印出的建议用户需要帮助解决他们的问题。

到目前为止,这是我的代码,但是当我输入一个关键字时,我已经放入代码以便代码可以识别它,输出就是一次打印的所有“建议”。谁能为我解决这个问题?

problem = raw_input("Hello. Welcome to the device help service. What is 
the problem with your device? ").lower()

if "cracked" or "crack" or "smash" or "smashed" in problem:
    print "(Resolution to damaged screen/cracked camera lens)"
elif "cracked" or "crack" or "smash" or "smashed" not in problem:
    None

if "dented" or "bent" or "snapped" in problem:
    print "(Resolution to damaged exterior)"
elif "dented" or "bent" or "snapped" not in problem:
    None

if "blurry" or "focus" or "picture" or "photo" in problem:
    print "(Resolution to damaged camera)"
elif "blurry" or "focus" or "picture" or "photo" not in problem:
    None

if "virus" or "hacked" or "glitch" or "popup" or "popups" in problem:
    print "(Resolution to infected device)"
elif "virus" or "hacked" or "glitch" or "popup" or "popups" not in problem:
    None

if "wet" or "water" or "moisture" in problem:
    print "(Resolution to wet device)"
elif "wet" or "water" or "moisture" not in problem:
    None

if "charged" or "power" or "turn" or "charger" or "battery" in problem:
    print "(Resolution to damaged battery/charging process)"
elif "charged" or "power" or "turn" or "charger" or "battery" not in         
problem:
    None

else:
    print "Sorry, we could not verify the issue your device has."

(请以我理解的方式回答,请记住,我有点愚蠢)

0 个答案:

没有答案