初級 › NameError: name 'x' is not defined の原因と直し方 › パターン2
NameError: name 'x' is not defined の原因と直し方
定義していない変数を参照したときに出る、最も頻出のエラーの一つです。
1 x = 5 2 print(___) ^
Traceback (most recent call last):
File "main.py", line 2, in <module>
print(y)
^
NameError: name 'y' is not defined
空欄を埋めて実行を通す
定義されていない名前を参照すると発生します。似た名前が存在しない場合は「Did you mean」の提案も出ません。
次の問題