You do not need while loop in your question, and number of months = years * 12
initial_investment = int(input('Enter Investment Amount:'))
annual_intrest = float(input('Enter Annual Investment Amount:'))
years = int(input('Enter Number of Years:'))
monthly_interest = annual_intrest/12
months = years*12
future_val_years = initial_investment * (1+annual_intrest)**years
future_val_months=initial_investment*(1+monthly_interest)**months
print('Accumulated value (monthly) is:', future_val_months)
print('Accumulated value (yearly) is:', future_val_years)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…