初級 › TabError: inconsistent use of tabs and spaces の原因と直し方 › パターン2
TabError: inconsistent use of tabs and spaces の原因と直し方
同じブロックの中でタブとスペースを混在させたときに出るエラーです。
1 x = 5 2 if x > 0: 3 y = 1 4 ____print(y) ^
File "main.py", line 4
print(y)
TabError: inconsistent use of tabs and spaces in indentation
空欄を埋めて実行を通す
1行目はスペース、2行目はタブ、というように混ざると発生します。エディタの設定でタブを自動的にスペースへ変換しておくと防げます。
次の問題