我想給量返回的基於家庭收入和這段代碼有什麼問題?它給出了一個錯誤
當我運行它,它說,孩子的數量:
Traceback (most recent call last): line 24, in main() line 5, in main print("Amount returned: ", amount(returned)) NameError: global name 'returned' is not defined >>> –
def main():
income = int(input("Please enter the annual household income: "))
children = int(input("Please enter the number of children for each applicant: "))
print("Amount returned: ", amount(returned))
def amount (returned):
if income >= 30000 and income < 40000 and children >= 3:
amnt = (1000 * children)
return amnt
elif income >= 20000 and income < 30000 and children >= 2:
a = (1500 * children)
return a
elif income < 20000 :
r = (2000 * children)
return r
else:
return "error"
main()
**它給了什麼**錯誤?它應該做什麼?不要只是把代碼轉儲給我們,*解釋你想要我們做什麼*。 –
當我運行它,它說:回溯(最近通話最後一個): 線24,在 的main() 5號線,在主 打印( 「額返回:」 量(返回)) NameError:全局名稱'returned'未定義 >>> –
user3341166
您是否定義了'returned'? – beerbajay