【发布时间】:2018-09-10 15:53:55
【问题描述】:
我是 python 新手, 我正在 python 3.7 中学习“if and else”条件。
所以问题是,当我输入我的代码时
def age_group(user_age):
x = int(input("Enter your age :"))
return x
if x < 150 :
print(age_group(x))
else :
print("Either he is GOD or he is dead")
但执行后我得到一个 NameError:-
Traceback (most recent call last):
File ".\Enter Age.py", line 6, in <module>
if x < 150 :
NameError: name 'x' is not defined
【问题讨论】:
-
请修正您的格式。
-
你的代码不是合法的python。您需要修复缩进。
标签: python python-3.x nameerror