Когда я закомментирую цикл for, все работает.Однако, как только он снова активен, IDLE выдает синтаксическую ошибку.Я попытался сделать это соответствующим образом, так как это было одним из предложений по другим вопросам, но это не сработало, независимо от того, сколько раз я нажимал ввод.
# futval.py
# A program to compute the value of an investment
# carried 10 years into the future
#begins main function of program
def main():
#description of program
print("This program calculates the future value")
print("of a 10-year investment.")
#creates and assign three variables to user input
principal = eval(input("Enter the initial principal: "))
apr = eval(input("Enter the annual interest rate: "))
compound = eval(input("How often is the interest compounded: "))
#begins a 'for' loop that iterates 10 times indicative of 10 years
for i in range(10):
print (principal)
principal = principal * (1 + (apr/compound)
#prints out the final result of the above equation.
print("The value in 10 years is:",principal)
#original program exited too fast and didn't allow user to see output
#I added the following line so the user could see.
print(input("Press enter to exit."))
main()