所以我一直在尝试运行以下代码:
def conference_call_discount(distance, basic_charge):
if(distance >= 50):
con_calc = basic_charge * 0.5
return con_calc
elif(distance < 50):
con_calc = 0
return con_calc
con_call = str(input("Is it a conference call? "))
from call_charge_functions import conference_call_discount
conference = conference_call_discount(dist, starting_cost)
if con_call == y:
print("your conference call discount is", conference)
else:
conference = 0
但是我仍然收到此错误: NameError:名称“ y”未定义
我不知道怎么了
答案 0 :(得分:2)
在这种情况下:
if con_call == y:
您没有设置y的值。
在比较之前,应为y变量设置一个值。