Skip to content Skip to sidebar Skip to footer

Embedded Function Returns None

My function returns None. I have checked to make sure all the operations are correct, and that I have a return statement for each function. def parameter_function(principal, annual

Solution 1:

monthly_payment_function does not return anything. Replace monthly_payment= with return (that's 'return' followed by a space).

Also you have an unconditional return before def monthly_payment_function, meaning it never gets called (strictly speaking, it never even gets defined).

Also you are pretty randomly mixing units, and your variable names could use some help:

from __future__ import division    # Python 2.x: int/int gives float

MONTHS_PER_YEAR = 12defmonthly_payment(principal, pct_per_year, years):
    months = years * MONTHS_PER_YEAR
    if pct_per_year == 0:
        return principal / months
    else:
        rate_per_year   = pct_per_year / 100.
        rate_per_month  = rate_per_year / MONTHS_PER_YEAR
        rate_compounded = (1. + rate_per_month) ** months - 1.return principal * rate_per_month * (1. + rate_compounded) / rate_compounded

Post a Comment for "Embedded Function Returns None"