TypeError: unsupported operand type(s) for +=: 'dict' and 'int'

Could anyone help me figure out where the problem is?

In order to increment the dict values, you have to access the dict values via its key. That is my_dict[key] += value_to_increment.

In your example, you can try comments_by_hour[hour] += comment.