2016-12-31 4 views
-2

でマイコード:i「はValueErrorを:解凍するためにあまりにも多くの値が(2予想)」どのように修正すればよいのPython

print("Welcome to the Apple troubleshooting program") 
query = input("Please type your problem and make sure all words are spelled correctly") 
problems = (('My phone does not turn on.', 
      {'power', 'turn', 'on', 'off'}, 
      ('Make sure the phone is fully charged.', 
       'Try hard-resetting the phone.', 
       'Buy a new battery and get it fitted by a professional.')), 
      ('My phone is freezing.', 
      {'freeze', 'freezing'}, 
      ('Clear the cache.', 
       'Free up memory by deleting unwanted apps and media.', 
       'If all fails, contact a professional.')), 
      ('The screen is cracked.', 
      {'cracked', 'crack', 'broke', 'broken', 'screen'}, 
      ('Contact your insurance company.', 
       'Purchase a new screen.', 
       'Get the screen fitted by a professional.')), 
      ('I dropped my phone in water.', 
      {'water', 'drop', 'dropped'}, 
      ('Buy a bag of rice big enough to house your phone.', 
       'Submerged the phone in the rice for 24-48 hours.', 
       'Take your phone out of the rice and it should have absorbed the moisture.'))) 


words = {''.join(filter(str.isalpha, word)) 
      for word in query.lower().split()} 
for problem, keywords in problems: 
     if words & keywords: 
      solution = input('Is this what the problem is?', problems) 
     else: 
      print("Sorry, I do not understand") 
     if solution == "yes": 
          print('Please follow these steps to fix your phone:') 
for number, step in enumerate(steps, 1): 

print('{}. {}'.format(number, step)) 
+1

あなたは 'problems'だけの長さ2のタプルが含まれているか、それが実際に含まれている3つのタプルを期待するために' for'ループを変更することを確認してください - '問題のために、キーワード、問題における解決策: '。 – jonrsharpe

+0

例を書式化してください。 – ppasler

+1

そして、あなたは 'input'の関数シグネチャを見つけて楽しくなるでしょう。あなたのヒントは 'input'は' print'ではないということです。 – TigerhawkT3

答えて

1

すべての項目あなたのproblemsリストでは3つの項目で構成され、ので、あなたのforループを解凍する必要があります3つの値:

for problem, keywords, solutions in problems: 
    ... 
+0

よろしくお願いします。 – vicev3nom

関連する問題