python エラー「IndentationError: expected an indented block after function definition on line x」が発生した場合の対処法

python エラー「IndentationError: expected an indented block after function definition on line x」が発生した場合の対処法

pythonで、エラー「IndentationError: expected an indented block after function definition on line x」が発生した場合の対処法を記述してます。関数内で正しくインデントが行われいないと発生します。pythonのバージョンは3.10.0を使用してます。

環境

  • OS windows11 home 64bit
  • python 3.10.0

エラー全文

以下のコードで発生

def hoge(x, y, z):
print(x + y + z)
    print(x - y - z)
    
hoge(1,2,3)

エラー全文

    print(x + y + z)
    ^
IndentationError: expected an indented block after function definition on line 1

原因

関数内での、インデントがされいないため

対処法

関数内はインデントを正しく行う

def hoge(x, y, z):
    print(x + y + z)
    print(x - y - z)
    
hoge(1,2,3)