2017-04-07 12 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

pythonでのインデントは、チュートリアルでカバーされます。 – Julien

+1

Pythonでは、空白が関係しています。あなたの圧痕は全面にあり、それは決してうまくいかないでしょう。 http://python.orgでPythonチュートリアルを見つけることができます –

+2

インデントの役割は、Pythonの教科書やチュートリアルの最初のレッスンです。これを知らずにどのようにして言語を学ぶことが可能ですか? – 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)) 

Pythonコードでは、常に適切なインデントが必要です。空白は問題です(Cとは異なります)!

Pythonの基本チュートリアルについてはthis tutorialをチェックアウトすることをお勧めします。

+1

@KenWhite十分に公正で、私は私の答えを詳述しました。 –

関連する問題