所以,基本上,这是我的代码:Python的检查用户输入
import random
import os
answer = input('What is the problem with your mobile phone? Please do not enter more than one sentence.')
print('The program has detected that you have entered a query regarding: '
if 'wet' or 'water' or 'liquid' or 'mobile' in answer:
print('Put your mobile phone inside of a fridge, it sounds stupid but it should work!')
我想知道的是,比方说,如果用户输入关键字“湿”和“移动”作为其输入,我怎么反馈给他们知道我的程序已经识别出他们的查询。
因此,通过说'如果程序检测到您输入了一个关于以下内容的查询:'我如何将它们的关键字过滤到这句话中,比如说,如果他们输入'我的手机最近变湿了',我想要不用说:
print('The program has detected that you have entered wet')
因为这听起来很蠢的IMO。
谢谢
把打印语句你'if'测试里面。实际上,你的整个if语句是无效的,需要重新编码。 – user590028
是的,我知道它应该是一个如果不是一个ELIF,我需要删除进口操作系统,我只是想尝试之前为什么有不需要的代码位 – Thom9son
但我想要一种方式来拉特定例如,如果有“有效输入”列表,并且来自用户输入的字符串中的一些字符串与列表匹配,那么它将打印所述字符串。 – Thom9son