Decision Tree split error During the split function of the decision tree, I am getting an assertion error stating:

Error &gt; Assert: type(C) == dict


I couldn't find any errors in the code up until now. Could you please correct it if there is any problem with it?

My code:

def split(X,Y,i):

    def __find_best_split(self):
                best_split = {}
                for column in self.X:     
                information_gain,split = 
    self.__find_best_split_for_column(column)
                    if split: continue
                    if not best_split or best_split["information_gain"] 
       &lt;information_gain:
                       best_split = 
    {"split":split,"col":column,"information_gain":information_gain}

                    C= (best_split)     

                return C
def __find_best_split(X, Y, i):
best_split = {}
for column in X:     
    information_gain,split = (2,3)#self.__find_best_split_for_column(column)
    if not split: continue
    if not best_split or best_split["information_gain"] &lt;information_gain:
        best_split = {"split":split,"col":column,"information_gain":information_gain}
C= (best_split)
return C


I ran this code in python 3.7 and it gave me the correct output: {'split': 3, 'col': 'a', 'information_gain': 2}. Also as pointed out by Ben Reiniger, it should be if not split: continue rather than if split: continue. In your case based on the indentation, C should never get defined or if indented properly, it should give empty dictionary. In both the scenario, getting error assert type(C) == dict does not makes sense.