我是Python和编程的初学者,所以我只理解有限的术语…我在while循环中添加时遇到了困难。除了我的第一个MoreExp之外,它添加了所有内容。我已经失去耐心了好几个小时了。如果有人能解释为什么这不会增加我所有的MoreExp,将不胜感激!在
#Loop to determine expenses
while MoreExp != "0":
MoreExp = input("Enter more expenses. If no more, enter '0': ")
TotalExp += int(MoreExp)
if MoreExp is "0":
AmountLeft = int(TotalIncome) - int(TotalExp)
TotalExp = int(TotalExp) + int(Expenses)
AmountLeft = int(TotalIncome) - int(TotalExp)
#Output total spent and amount leftover
print("Total amount spent from income: $", TotalExp)
print("Total amount left over after expenses: $", AmountLeft)
我得到的结果是:
^{pr2}$我刚想好了!!我不小心在循环开始之前向用户请求MoreExp,所以它没有将它添加到TotalExp中。感谢那些帮助过我的人!!很抱歉给你添麻烦了。。在
试试这样
对不起,我把你的全部代码都重做了,但现在可以用了!在
试试这个让我知道:)
相关问题 更多 >
编程相关推荐