print("Hi! This program has a lot of errors, please fix them ")
print("What class is this?")
the_class = input()
if the_class == UST220:
print("Correct, this is", the_class)
else:
print("Oh, you seem to not be in the right class.")
print("I would like to numerically add these two numbers together.")
x == 2
y = 3
z = x + y
print(z)
我必须修复此代码中的所有错误,但是每次运行它都会收到一个错误
NameError Traceback (most recent call last)
<ipython-input-56-f7baa07e8761> in <module>
3
4 the_class = input()
----> 5 if the_class == UST220:
6 print("Correct, this is", the_class)
7 else:
NameError: name 'UST120' is not defined
我必须修复此代码中的所有错误,但我无法弄清楚NameError的含义
答案 0 :(得分:0)
NameError表示变量名称不存在。在您的情况下,if条件中使用的UST220尚未定义。如果是字符串,可能必须将其放在引号内
答案 1 :(得分:0)
此行:
200
导致错误,因为UST220被视为尚未实例化的变量。由于您要输入字符串,因此请执行此操作。
if the_class == UST220: