I wrote a program in python to find compound interest (more like copied). This program was written in python 2 and I am having a problem on the last line .format(years).
I need to know what I can do with this code, and how to write it properly in Python 3. Also with the {} part in the last line. Should I change it to %s? The error says:
"AttributeError: 'NoneType' object has no attribute 'format'".
My code looks like this :
# Estimated yearly interest
print ("How many years will you be saving ? ")
years = int(input("Enter the number of years : "))
print("How much money is currently in your account ? ")
principal = float(input("Enter current amount in account : "))
print("How much money do you plan on investing monthly ? ")
monthly_invest = float(input("Monthly invest : "))
print("What do you estimate the interest of this yearly investment would be ? ")
interest = (float(input("Enter the interest in decimal numbers (10% = 0.1) : ")))
print(' ')
monthly_invest = monthly_invest * 12
final_amount = 0
for i in range(0, years ):
if final_amount == 0:
final_amount = principal
final_amount = (final_amount + monthly_invest) * (1 + interest)
print("This is how much money you will have after {} years: ").format(years) + str(final_amount)