lundi 31 mai 2021

I get an unexpected NoneType error in my if-statement

I am trying to debug some code that for some reason returns TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

The if statement should trigger on the else condition (not first month of quarter), and should return the output of the calculation.

import pandas as pd
from datetime import date

    def getInterest(self):
        today = date.today()
        current_month = today.month 
        if current_month == [1,4,7,10]:
            print("First month of quarter")
            return 50
        else:
            print("Not first month of quarter")
            return (30000*-1*((0.03/365)*30))*0.9
  File "C:\Git\xxx\xxx.py", line 49, in getInterest
    return 30000*-1*((0.03/365)*30))*0.9
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

What am I missing here? I don't see why I get the NoneType error.

Aucun commentaire:

Enregistrer un commentaire