Code Fix

初級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

空欄を埋めて実行を通す

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

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

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

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

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