初級 › IndentationError: expected an indented block の原因と直し方 › パターン1
IndentationError: expected an indented block の原因と直し方
if・for・def・whileの本体を書き忘れたときに出る、Python学習者が最初につまずくエラーです。
1 if True: 2 ____print("yes") ^
File "main.py", line 2
print("yes")
^^^^^
IndentationError: expected an indented block after 'if' statement on line 1
空欄を埋めて実行を通す
ifの本体は必ずインデントが必要です。コロンの後で改行しただけでは、Pythonはどこまでが本体か判断できません。
次の問題