fairly new to programming and trying to learn Python at the moment. I have this code and I don\'t understand why I don\'t get a return value :(
balance = 3200
an
You're being unclear about what function you expect to return a value, but as I cannot comment and prod yet I'll provide a possible answer.
First of all, in this code you never actually call any of the functions. I'm assuming this is done elsewhere.
As for f(x)
, there's no return value
because you have not made a Return
statement. I would also refrain from using variables as Globals, it's typically bad practice. Instead, if you want to modify MonthlyInterestRate
send it as a parameter to f()
and return the new value.
bisection
only returns if f(c) == 0
but f()
does not have a Return
statement, so that will never happen. Past that, once it exits the loop it will only print c so no return value there either.
If you want to compare a function, it NEEDS a Return
statement.