The objective of this script is to provide the number of years it takes to reach target amount of money given the starting amount and annual interest rate.
I get the error :UnboundLocalError: local variable 'currentamt' referenced before assignment
startamt = float(input("Starting Amount?: "))
targetamt = float(input("Target Amount?: "))
air = float(input("Annual Interest Rate? "))
currentamt = 0
year = 0
def main():
currentamt = startamt * air + currentamt
while currentamt < targetamt:
year = year + 1
print('year')
if __name__ == '__main__':
main()