TypeError: list indices must be integers, not str (boolean convertion actually)

Only change that needs to be made is that features must be initialized to a dict ({}) rather than a list ([]) and then you could populate it’s contents. The TypeError was because word_features is a list of strings which you were trying to index using a list and lists can’t have string indices. Here, the elements present in word_features constitute the keys of dictionary, features holding boolean values, True based on whether the same … Read more