所以,根据我的守则:
ValidInputs = ['wet', 'water', 'liquid', 'mobile', 'iphone']
root = Tk()
def iphone():
while True:
Problem = input('State your problem')
ProblemSplit = Problem.split(' ')
if any(Words in ValidInputs for Words in ProblemSplit):
print('Put your phone in the fridge for about 30 minutes, it will remove the moisture inside of your phone')
time.sleep(2)
这是可行的,但我认为效率低下。举例来说,如果我使用Problem变量的输入,并输入'my phone is wet',它将检测到wet确实在ValidInputs列表中,但是每次它都会打印相同的答案/解决方案。因此,如果我在ValidInputs列表中添加了更多可接受的条目,我不希望它总是打印相同的“将手机放入冰箱”等。在
那么,我该如何创建一个具有以下格式的词典, 查询:解决方案 这样,如果问题分割中有任何单词出现在查询中,则打印解决方案。 有什么建议吗?
我已经尝试了一个小时了,但是没有运气,我已经很接近了,但是到目前为止,如果你明白我的意思,通过我自己的研究,但是它变得很无聊,所以
感谢任何帮助。在
这里有一个最小的例子,我相信你在寻找什么。在
相关问题 更多 >
编程相关推荐