lundi 24 octobre 2016

IF condition Python "local variable 'monthlyPayment' referenced before assignment"

Following are my code

def getMonthlyPayment(self,annualInterestRate,loanAmount,numberOfYears,loan):

       if  loan ==0 and (annualInterestRate*1-loanAmount)>=2 and numberOfYears<=3:
         monthlyPayment = min((annualInterestRate * 1 -loanAmount),10)
       return monthlyPayment
       elif   loan ==1 and (annualInterestRate*2-loanAmount)>=2 and numberOfYears<=3:
        monthlyPayment = min((annualInterestRate * 2-loanAmount),20)
       return monthlyPayment
       elif   loan >1 and (annualInterestRate*4-loanAmount)>=2 and numberOfYears<=3:
        monthlyPayment = min((annualInterestRate * 4 -loanAmount),20)
       return monthlyPayment
       else:
        monthlyPayment='Not Qualify'
       return monthlyPayment

Aucun commentaire:

Enregistrer un commentaire