初級 › 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
空欄を埋めて実行を通す
関数定義も本体のインデントが必須です。波括弧を使わないPythonでは、インデントそのものがブロックの境界を表します。
次の問題