Reputation: 1
I am trying to create a program that asks the user their principal, interest rate, and total amount of years. I want my program to show them the amount of total return they would expect for each year. I want it to start at year 1. When I run my script, it only shows one year's worth total interest. Here is what I have so far.
#Declare the necessary variables.
princ = 0
interest = 0.0
totYears = 0
year = 1
#Get the amont of principal invested.
print("Enter the principal amount.")
princ = int(input())
#Get the interest rate being applied.
print("Enter the interest rate.")
interest = float(input())
#Get the total amount of years principal is invested.
print ("Enter the total number of years you're investing this amonut.")
totYears = int(input())
for years in range(1, totYears):
total=year*interest*princ
years += 1
print (total)
Thank you any help is appreciated.
Upvotes: 0
Views: 1295
Reputation: 77857
There are problems here:
for years in range(1, totYears):
total=year*interest*princ
years += 1
print (total)
Perhaps you need this:
for years in range(1, totYears):
total = years * interest * princ
print (total)
Upvotes: 1