我在Python 2.7简单的for循环和打印
我做了一些非常基本的练习我工作,这是我的代码:
def main():
print """Program computes the value of an investment
carried 10 years into the future"""
principal = input("Enter the principal: ")
apr = input("Provide (in decimal format) the annual percentage rate: ")
for i in range(10):
principal = principal * (1 + apr)
print "The value in 10 years will be: $", principal
main()
的代码工作,但我所要的输出只是最终的结果。现在我所得到的是循环的所有10个步骤被一个接一个地打印出来。
我该如何解决这个问题?
那么简单。多谢。 – nutship