Code Fix

初級IndentationError: expected an indented block の原因と直し方 › パターン2

IndentationError: expected an indented block の原因と直し方

if・for・def・whileの本体を書き忘れたときに出る、Python学習者が最初につまずくエラーです。

 1  def greet():
 2  ____print("hi")
      ^
File "main.py", line 2 print("hi") ^^^^^ IndentationError: expected an indented block after function definition on line 1

空欄を埋めて実行を通す

広告
広告スロット(未設定)

IndentationError: expected an indented block の原因と直し方

波括弧の代わりにインデントでブロックを表すPythonならではの挙動を整理します。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)