cat_sums[cat] += value
TypeError: 'int' object is not iterable
私の入力はこれです:
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]})
そして、これは 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
私が知る限り、私は整数を反復しようとしていません。catnums 内の別の値に値を追加しようとしています。
Accumulate_by_category() 関数内の「cats」引数に問題がある可能性はありますか?