2017-04-07 5 views
-7

"IndentationError : unentent가 모든 들여 쓰기 수준과 일치하지 않습니다"라는 오류가 있습니다. 명령을 사용하여 시도하고 공백과 탭을 변경했지만 오류가 계속 나타나고 모든 문자를 시도했습니다. 포럼에서 읽을 수 있지만 여전히 같은 부분에 표시되는 오류가 오류 부분 도움을 주시기 바랍니다있다 : bullets.update() ^ 코드 :Identifier Error

def update_bullets(bullets): 
"""Update position of bullets and gets rid of old bullets""" 
#Update bullet position 
bullets.update() 

# Get rid of bullets that had dissapeared 
    for bullet in bullets.copy(): 
     if bullet.rect.bottom <= 1: 
      bullets.remove(bullet) 
     print(len(bullets)) 
+5

파이썬의 들여 쓰기는 튜토리얼에서 다루어집니다. – Julien

+1

파이썬에서는 공백이 적합합니다. 귀하의 들여 쓰기가 모든 곳에 있으며, 그것은 결코 작동하지 않을 것입니다. http://python.org에서 파이썬 튜토리얼을 찾을 수 있습니다 –

+2

들여 쓰기의 역할은 거의 모든 파이썬 교과서 또는 튜토리얼의 첫 번째 교훈입니다. 이것을 모른 채 어떻게 언어를 배울 수 있습니까? – Barmar

답변

2

에 코드를 제대로 들여 쓰기, 다음과 같아야를 :

def update_bullets(bullets): 
"""Update position of bullets and gets rid of old bullets""" 
    #Update bullet position 
    bullets.update() 

    # Get rid of bullets that had dissapeared 
    for bullet in bullets.copy(): 
     if bullet.rect.bottom <= 1: 
      bullets.remove(bullet) 
     print(len(bullets)) 

파이썬 코드는 항상 들여 쓰기가 필요합니다. 공백은 중요합니다 (C와는 다릅니다)!

파이썬에 대한 기본 자습서는 this tutorial을 확인하시기 바랍니다.

+1

@KenWhite 충분히 공정하게, 나는 내 대답에 대해 자세히 설명했다. –