2016-09-03 2 views
-2

내가 그렇게 계속 실행 나던 코드를 어떻게해야 enter image description here코드를 수정하려면 어떤 기능을 사용해야합니까?

... 나는 아마추어 파이썬에서 간단한 문제 해결사를 코딩하기 위해 노력하고있어하지만 난 이런 일이 발생을 중지하는 데 사용하는 필요한 기능을 확신 사용자가 예를 입력하면?

TxtFile =open('Answers.txt') 
lines=TxtFile.readlines() 
import random 
def askUser(question): 
    answer = input(question + "? ").lower() 
    Split = answer.split() 
    if any(word in Split for word in KW1): 
     return False 
    elif any(word in Split for word in KW2): 
     return True 
    else: 
     print("Please answer yes or no.") 
     askUser(question) 

KW1=["didn't", "no",'nope','na'] #NO 
KW2=["did","yes","yeah","ya","oui","si"] #YES 
print (lines[0]) 

print("Nice to meet you, " + input("What is your name? ")) 
print("Welcome to my troubleshooter") 
#This is the menu to make the user experience better 
shooter=True 
while shooter: 
    print('\n\n1.Enter troubleshooter\n2.Exit\n\n') 
    shooter=input('Press enter to continue: ') 
    if shooter==('2'): 
     print('Ok bye') 
     break 



words = ('tablet', 'phone', 's7 edge') 
while True: 
    question = input('What type of device do you have?: ').lower() 
    if any(word in question for word in words): 
      print("Ok, we can help you") 
      break     
    else: 
      print("Either we dont support your device or your answer is too vague") 

if askUser("Have you tried charging your phone"): 
    print("It needs to personally examined by Apple") 
else: 
    if askUser("Is it unresponsive"): 
     print (lines[0])   
    else: 
     print ("Ok") 
    if askUser("Are you using IOS 5.1 or lower"): 
     print (lines[1]) 
    else: 
     if askUser("Have you tried a hard reboot"): 
      print (lines[2]) 
     else: 
      if askUser("Is your device jailbroken"): 
       print (lines[3]) 
      else: 
        if askUser("Do you have a iPhone 5 or later"): 
         print (lines[4]) 
        else: 
         print(lines[5]) 
      print ('Here is your case number, we have stored this on our system')   
      print (random.random()) 

다음은 참조 용 코드입니다.

편집 : 여기에 문제 enter image description here

그냥 거기에 코드를 종료해야하지만이 나던입니다. 나는 다음은

+0

'askUser' 함수와'lines [0] - [2]'의 출처를 포함한 전체 코드를 게시 할 수 있습니까? – Harrison

+0

질문을 업데이트 해 주셔서 감사합니다. 어디에서 오류가 발생합니까? 코드의 특정 부분을 지적 할 수 있습니까? 또한 일부 들여 쓰기는 일부 지점에서 수정해야하는 것처럼 보입니다. 코드를 들여 쓰기 위해 탭과 공백을 모두 사용하고 있습니까? – Harrison

+0

전체 코드를 게시했습니다. 나는 이것을 구성하는 txt 파일에서 0-2 줄을 인쇄하고있다. 애플에게 아이폰을 다시 보내야한다. 설정에서 소프트웨어를 업데이트해야합니다. 불행히도 우리가 할 수있는 일이 많지 않고 장치를 수리해야합니다. iPhone을 Jailbreaking하면 보증 위반입니다. Apple은 더 이상 당신을 도울 수 없습니다. 휴대 전화를 초기화해야합니다. Apple 고객 서비스를 이용해 주셔서 감사합니다. 이 문제가 해결되지 않아 죄송합니다. 사례 번호 # – user5676036

답변

-2

내가 이동하는 것이 좋습니다 해결할 수있는 방법을 잘 모르겠어요 :

if askUser("Are you using IOS 5.1 or lower"): 
     print (lines[1]) 
    else: 
     if askUser("Have you tried a hard reboot"): 
      print (lines[2]) 
     else: 
      if askUser("Is your device jailbroken"): 
       print (lines[3]) 
      else: 
       if askUser("Do you have a iPhone 5 or later"): 
        print (lines[4]) 
       else: 
        print(lines[5]) 
       print ('Here is your case number, we have stored this on our system')   
       print (random.random()) 

의 다른 부분으로 :이 도움이

if askUser("Is it unresponsive"): 

희망.

관련 문제