如何让我的程序区分两种不同的途径?

时间:2016-04-20 21:58:19

标签: python list if-statement while-loop

所以基本上我有这个程序,它将用户关于电话的问题与存储在列表中的问题中的单独单词进行匹配。一旦扫描了所有单词,可能已经匹配了一些,并且可以针对用户的不同问题给出一些解决方案:

while **num  == len(words)**:
    if words[num] in storage:
        keyword = storage.index(words[num])
        while not "{" in storage[keyword]:
            keyword+=1
        answer = storage[keyword].replace("{", "")
        print (answer)
        num+=1
    elif **num==len(words)**:
        print("Thank you for using this troubleshooting process and we hope that we have solved your problem.")
        break
    else:
        num+=1
        continue
print("No solution has been found to your problem. Please rephrase your sentence and try running this troubleshooting system again. Thank you.")

如上所述,如果没有匹配的话,程序会告诉用户没有找到解决方案。但是,如果扫描了所有单词并且其中一些单词匹配,那么如何区分这两个单词,因为它们都具有相同的代码?

0 个答案:

没有答案