2014-12-24 1 views
0

이 책의이 시점에서 기능을 호출하는 작은 비디오 게임을 만들도록하는 책을 살펴 보겠습니다. if, while의 - 모든 것 지금까지 책에서 다루어졌다. 하지만이 코드에서이 오류가 발생합니다.구문 및 들여 쓰기 오류에 대한 문제

코드가 편집되었으며 새로운 오류가 나타납니다. 여기

File "ex35_study.py", line 24 third_scenario_code() IndentationError: unindent does not match any outer indentation level 

내 코드입니다 :

 options_thirdscenario_actions = ['Examine the door', 'Try to force it'] 

def third_scenario_code(): 
    print "Let me try to crack this thing up, says Lars as he starts to type in the panel. You hear the sounds of the fight out there, there's not much time left. " 
    print "After receiving several commands a window with a code pop ups. " 
    print codefile.read() 


def third_scenario(): 
    print "You two get out of the cell and approach to the exit, a long corridor is ahead of you, flashing red lights indicate an state of emergency, you must evacuate." 
    print "As soon as you two approach to the door, it closes" 
    print "Crap it must be the emergency system, we have been detected" 
    next = raw_input("What do you do> ") 
if next == 'Examine the door': 
    print "A small panel comes out, requires to enter a code of words" 
    third_scenario_code() 
elif next == 'Try to force it': 
    print "You try to force the door with no result" 
    print options_thirdscenario_actions  
    next2 = raw_input("What else do you do> ") 
    if next2 = 'Examine the door' 
     third_scenario_code() 
else: 
    print "You already did that" 

내가 전체 프로그램에 유사한 오류가 발생하고 있는데 나는 그것이 들여 쓰기 함께 할 수있는 뭔가가 생각,하지만 난 모든 시도했다 제안 나는 결실 결과없이 구글에서 볼 수 있습니다. 미리 감사드립니다.

+0

'third_scenario_code()'는 들여 쓰지 않아야합니다. –

+0

'third_scenario_code'-lines는 들여 쓰기가 잘못되었습니다. 사용자 탭과 항상 들여 쓰기를위한 4 칸을 절대로 사용하지 마십시오. 편집기를 구성하여 도움을 받으십시오. – Daniel

답변

0

들여 쓰기가 third_scenario_code()이기 때문에 print으로 작성해야합니다. 인쇄 후 즉, 동일한 범위까지 것들을 줄 필요가있는 일 if의 조건 후에

if next == 'Examine the door': 
      print "A small panel comes out, requires to enter a code of words" 
      third_scenario_code() 
+0

방금 ​​언급 한 내용이 나왔지만 새로운 오류가 나타납니다. 솔직히 말해서이 두 가지 유형의 오류는 전체 코드를 통해서만 해결할 수 있습니다. –

+1

@LittleFoot 그래서 공백과 탭을 섞어서 코드 중 하나를 사용하십시오! – Kasramvd

+0

문제는 공간 키를 4 번 누르고 있는데도 여전히 오류가 발생합니다. 나는 또한 공간을 위해 Notepad ++를 수정했다 –

1

당신은 누락 콜론과 :

if next == 'Examine the door': 
      print "A small panel comes out, requires to enter a code of words" 
       third_scenario_code() 

에 다음

변화 함수 호출하지만 공백과 탭을 섞을 수도 있습니다. 탭이 아닌 항상 4 칸을 사용하는 것이 좋으며, 대부분의 프로그래밍 편집자가 이것을 설정할 수 있습니다.

나는 또한 pylint을 잡고 그것을 사용하는 것이 좋습니다. 잠재적 인 오류를 많이 발견하고 좋은 습관을 개발하는 데 도움이됩니다.