3 回答

TA贡献1946条经验 获得超4个赞
取消最后一行的缩进(请不要再使用1个空格缩进,PEP-8建议使用4个空格)
def main():
print "This program calculates the future value of a 10-year investment."
principal = input("Enter the initial principle: ")
apr = input("Enter the annual interest rate: ")
for i in range(10):
principal = principal * (1 + apr)
print "The value in 10 years is:", principal

TA贡献1848条经验 获得超6个赞
只需将print行移出for-loop即可:
for i in range(10):
principal = principal * (1 + apr)
print "The value in 10 years is:", principal

TA贡献1829条经验 获得超9个赞
with open("story.txt",encoding="utf-8") as f:
for line in f:
for word in line.split()
aList.append( word )
print(aList)
添加回答
举报