Pobieranie obiektu „int” nie jest iterowalne

    cat_sums[cat] += value
TypeError: 'int' object is not iterable

Moje dane to:

defaultdict(<type 'list'>, {'composed': [0], 'elated': [0], 'unsure': [0], 'hostile': [0], 'tired': [0], 'depressed': [0], 'guilty': [0], 'confused': [0], 'clearheaded': [0], 'anxious': [0], 'confident': [0], 'agreeable': [0], 'energetic': [0]})

A to jest przypisane do czegoś zwanego catnums

accumulate_by_category(worddict, catnums, categories)

        def accumulate_by_category(word_values, cat_sums, cats):
                for word, value in word_values.items():
                        for cat in cats[word]:
                                cat_sums[cat] += value

Teraz, o ile wiem, nie próbuję iterować po liczbie całkowitej. Próbuję dodać wartość do innej wartości w catnums.

Czy to możliwe, że ma problem z argumentem „cats” w mojej funkcji accumulate_by_category ()?

questionAnswers(3)

yourAnswerToTheQuestion