class Mortgage:
    """ Mortgage payment calculator """


    def __init__(self, loan_value, interest_rate, length, interval):
        self.lv = loan_value
        self.ir = interest_rate / 100
        self.length = length
        self.interval = interval
        
        if self.interval == "Monthly":
            self.ninterval = 12
        elif self.interval == "Weekly":
            self.ninterval = 52
        elif self.interval == "Daily":
            self.ninterval = 365
        else:
            self.ninterval = 1


    def calc_int(self):
        i = self.ir / self.ninterval
        n = self.length * self.ninterval
        int_multiplier = (1 + i)**n
        return int_multiplier

    def calc_payment(self):
        p = self.lv
        i = self.ir
        imult = self.calc_int()
        
        cost = p * (i*(imult) / (imult - 1))
        cost = cost / 12
# 4.467744314010732 -- 4.481228688522581
        return cost

ite = 'Yes'
while ite == 'Yes':
    loaninput = float(input("Please enter your total mortgage value >>> "))
    irinput = float(input("Please enter the interest rate for the mortgage (in %) >>> "))
    linput = float(input("Please enter the loan length (in years) >>> "))
    iinput = input("Please enter a compounding interval (Choices: Monthly, Weekly, Daily or Default) >>> ")

    user_mortgage = Mortgage(loaninput, irinput, linput, iinput)

    print("The monthly payements of your fixed term mortgage, over " + str(int(round(user_mortgage.length))) + " years, are of " + str(user_mortgage.calc_payment()) + "$ per month.")

    ite = input("Do you want to calculate another mortgage?(Yes/No) >>> ")








