2016-10-10 16 views
-6

次のコードはPythonの自動トラブルシューティングツールです。Python "trouble shooting machine"に修正が必要

# Welcoming the user to the program 
print("Hello this is a automated mobile phone troubleshooter ") 
print("The code will ask you a few questions try to answer them to the best of your ability") # Explaining what the code will do 

# A list storing all the questions the code will ask the user 
questions = ["Is there a problem with your hardware or is do you need technical assistance. Please type technical assistance or hardware", 
      "Have you dropped your phone recently? Please type Yes or No", 
      "Is your phone able to charge? please type Yes or No", 
      "Is your phone a iphone? Please type yes or no", 
      "Does your phone keep freezing? Please type yes or no", 
      "Can your phone connect to wifi? please type either yes or no", 
      "Have you gotten your phone wet? ", 
      "Is the phone's screen cracked or broken? ", 
      "Is there a problem with the camera? ", 
      "Is the problem with phone fixed? "] 
# A list containing all the solutions that will be given to the user 
solutions = ["This troubleshooter is only for hardware problems please call 01474 709853 for technical assistance", 
      "Please try turning it off and on again", 
      "Try changing the cable you charge the phone with", 
      "Please hold the lock button and home button for 5 seconds this causes a force restart", 
      "Try deleting some data to make your phone run faster E.G. Delete applications", 
      "Try restarting your router", 
      "Put your phone in a bowl of rice overnight", 
      "Take the phone to the manufacturer's store", 
      "Uninstall any third party apps or applications that you have downloaded since the camera has not been working", 
      "Please take the phone to your local phone manufacturers store and ask them for help"] 
answers = ["technical assistance","yes","no","yes","yes","no","yes","yes","yes","no"] 
validation = ["hardware","no","yes","no","no","yes","no","no","no","yes"] 
answer = "a" 
# Creating a loop and making the variable loop go from 0 to 9 
for loop in range(0,10): 
    while answer != answers[loop] and answer != validation[loop]: 
     answer = input(questions[loop]) 
     # Turning the user's answer and turning it to lowercase making sure the IF statement gets the right answer 
     answer = answer.lower()  
     if answer == answers[loop]: 
      # prints the solution the problem 
      print(solutions[loop]) 
      else goto 

print("Thank you for using the automated troubleshooting program goodbye") 

終了する前に最大2つの質問を入力できるため、このコードを正しく実行することはできません。誰かが助けることができる方法はありますか?

+0

あなたは、コードのボックス内のコードをフォーマットしようとしてもらえますか? http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks –

+0

コードを正しくフォーマットしてください。システムが巨大なコードブロックと小さなテキストで質問することができないなら、それには理由があります(cc。@MartinGottweis)。あなたの質問には情報がありません。 [ask]をお読みください。 –

+2

私が見たのは、25年前のc64のベーシックで遊んでいたときのようなものでした。 – grubjesic

答えて

-1

"if文"とraw_inputで何をするのですか?

x = raw_input("Is there a problem with your hardware or is do you need technical assistance. Please type technical assistance or hardware") 

if x == ("technical assistant"): 
    print("This troubleshooter is only for hardware problems please call 01474 709853 for technical assistance") 

if x == ("hardware"): 
    x1=raw_input("Have you dropped your phone recently? Please type Yes or No") 

if x1 == ("No"): 
    x2=raw_input("Is your phone able to charge? Please type Yes or No") 

のように...

+0

あなたの答えは不明です。それは未定義の 'x1'に簡単につながる可能性があります。 –

関連する問題