初級 › NameError: name 'x' is not defined の原因と直し方 › パターン3
NameError: name 'x' is not defined の原因と直し方
定義していない変数を参照したときに出る、最も頻出のエラーの一つです。
1 price = 100 2 tax_rate = 0.1 3 print(price + ________) ^
Traceback (most recent call last):
File "main.py", line 3, in <module>
print(price + tex_rate)
^^^^^^^^
NameError: name 'tex_rate' is not defined. Did you mean: 'tax_rate'?
空欄を埋めて実行を通す
スネークケースの変数名はタイプミスに気づきにくいです。1文字違いでも別の名前として扱われます。
次の問題