【发布时间】:2017-02-28 00:30:39
【问题描述】:
第二个循环不起作用。当我编译它不输出任何文本,它只是要求输入并停在那里
这意味着第二个循环没有被执行,只是第一个但我不知道为什么
balance0 = float(input("balance = " ))
annualInterestRate = float(input("annualInterestRate = " ))
monthlyPayment = 10
balance = 0
month = 1
while (0):
balance = balance0
while month <= 12:
balance1= (balance + annualInterestRate * balance/12)
balance1 = balance1 - (monthlyPayment)
print("Remaining balance month " , month, " is ", balance1)
balance = balance1
month += 1
if balance < 0:
print("Lowest payment: ", monthlyPayment)
break
else:
monthlyPayment += 10
循环
while month <= 12
无法运行,为什么?
【问题讨论】:
-
因为你有条件
while (0),它转换为while False,它永远不允许你输入下面的语句。你不想要while balance != 0或类似的东西吗? -
while(0)永远不会为真,因此不会被执行。 -
如果你问我,看起来两个循环都不起作用
标签: python