Apr-26-2019, 10:39 AM
Hi,
I am totally new to Python and programming. However, I tryed to create a simple function, which is not working. Please help.
NameError: name 'years' is not defined
even though I am returning the values with my function. What am I doing wrong?
I am totally new to Python and programming. However, I tryed to create a simple function, which is not working. Please help.
def money(capital, years, added_yearly, interest):
a = 0
while a < years:
capital = (capital+added_yearly)*interest
a = a+1
return (capital, years)
money(33000, 5, 3000, 1.1)
print("Your capital after %s years will be %s" % (years, capital))When I am trying to run this code with PowerShell, it give me the error: NameError: name 'years' is not defined
even though I am returning the values with my function. What am I doing wrong?
