我是一名初学者,并尝试构建预算计算器。我坚持使用if和else语句,因为它在运行时似乎无视else语句,并且对我的输入内容并不重要。我的代码如下所示:
Salary = int(input("Money you get paid a month: "))
Other_Incomes = str(input("Do you have any other sources of income? Y/N \n"))
if Other_Incomes == str("N") or str("n"):
Other_Incomes1 = 0
else:
Other_Incomes1 = int(input("How much do you make from your other sources of income: "))
print(Other_Incomes1)
例如,当我在“薪金”中输入50,然后询问我回答“ Y”的问题时,它会显示0 ...有人可以帮忙吗?!
我正在python 3.7.0中工作