辞書を正常にインポートできます。その値の辞書から出力を取得できますが、ユーザーの入力と一致する値ではなくすべての値が表示されます。入力を使用して辞書値を表示
入力は最初に下位に変換され、次に辞書内で参照される個々の単語に分割されます。
# prob_dict : dictionary
# problemlist : input lowercase and split
私は多くの投稿を検索しましたが、解決する解決策が見つかりません。
problemlist = problem1.split()
for problem in range(len(prob_dict)):
if prob_dict in problemlist:
solution = []
solution = (prob_dict[problem])
print('Your Solution is:', solution)
else:
print('could not find a solution')
辞書には、次のとおりです。
prob_dict = {'wet': ['put in bag of rice to dry out'],
'screen': ['screen will need to be replaced'],
'charger': ['purchase new charger for our store']
}
をと 'problem1'は何ですか? –
こんにちは、私はあなたの質問を理解していません。あなたは詳細を教えていただけますか? –
MCVEを提供してください([最小限の完全かつ検証可能なサンプルを作成する方法](https://stackoverflow.com/help/mcve)を参照)。 – martineau