2017-11-07 7 views
-4

저는 일반적으로 파이썬과 프로그래밍에 익숙하지 않습니다. 나는 College on Summer Term에 앞장서려고 노력하고있어. 나는이 초급 책에서 배우려고 노력하고 있으며, 다음 코드를 정확히 쓴다. 나는 어느 방향 으로든 들여 쓰기 공간을 변경하려고 시도했지만 여전히이 메시지를 얻는다. 나는 아마 내가 여기에 뭔가를 놓쳤다는 것을 이해하지만 나는 어떻게해야하는지에 대한 조언을 고맙게 생각할 것이다.들여 쓰기가 새롭고 들러 붙음 오류 : 들여 쓰기 된 블록이 예상 됨

Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)] 


    >>> # Ghost Game 
    ... from random import randint 
    >>> print('Ghost Game') 
    Ghost Game 
    >>> feeling_brave = True 
    >>> score = 0 
    >>> while feeling_brave: 
    ... ghost_door = randint(1, 3) 
    File "<stdin>", line 2 
    ghost_door = randint(1, 3) 
      ^
    IndentationError: expected an indented block 
    >>> ghost_door= randint(1, 3) 
    >>> while feeling_brave: 
    ... ghost_door= randint(1, 3) 
    File "<stdin>", line 2 
    ghost_door= randint(1, 3) 
      ^
IndentationError: expected an indented block 
>>> while feeling_brave: 
... ghost_door = randint(1, 3) 
    File "<stdin>", line 2 
    ghost_door = randint(1, 3) 
      ^
    IndentationError: expected an indented block 
    >>> while feeling_brave: 
    ... ghost_door = randint(1,3) 
    File "<stdin>", line 2 
     ghost_door = randint(1,3) 
      ^
    IndentationError: expected an indented block 
    >>> while feeling_brave: 
    ... ghost_door =randint(1,3) 
    File "<stdin>", line 2 
    ghost_door =randint(1,3) 
+1

들으십시오. 들여 쓰기를 수정하십시오 (Google에서 알 수없는 방법을 모르면) –

+0

들여 쓰기 만하면됩니다. 'ghost_door'에 들여 쓰기 만하면됩니다. 오류가 마치라고 말했듯이 – kstullich

+0

그래서 나는 그것을 이해하기 때문에 'g'앞에 들여 쓰기를 할 수 있습니까? 미안 해요, 여전히 레이아웃을 이해하려고합니다. – Joseph

답변

0

"while"문 뒤에는 "..."이 표시됩니다. 다음 행의 시작 부분에 4 개의 공백을 입력하여 들여 쓰기를 제공해야합니다.

+0

왜 4 칸입니까? – TZHX

+0

@TZHX 이는 들여 쓰기와 동일하기 때문입니다. – VortexYT

+0

그래서 하나의 공간입니다. 또는 탭. – TZHX

0

현재

... ghost_door = randint(1,3) 

라인에 기존의 들여 쓰기의 앞에 [TAB]를 눌러 들여 쓰기를 추가는, 당신은 가지고있다 :

while feeling_brave: 
    ghost_door = randint(1, 3) 

당신은 "문"에 대한 없어요 들여 쓰기로 루프를 처리하므로 인터프리터는 두 개의 연속 된 명령으로 처리합니다. 그러나, 가지고있는

while feeling_brave: 
    ghost_door = randint(1, 3) 

은 루프가 실행되는 동안 두 번째 줄을 실행하도록 통역사에게 알립니다.

+0

bsckticks를 사용하는 대신 4 줄 간격으로 코드 서식을 들여서 새 줄을 유지합니다. – TZHX

+0

@TZHX 새로운 라인을 보존한다는 것은 무엇을 의미합니까? – VortexYT

+0

답변을 보면 코드가 예상 한 것처럼 보이나요? – TZHX