It’s telling you what’s wrong: you can’t change the size of
total_personality_count_dict while iterating through it. You can’t use
pop(). Since you are doing addition, what you can do instead is update the value of the field you want to “remove” to 0, so any future addition done with it will not have any effect.
total_personality_count_dict[personality_2] = 0
And if you want a dictionary without
personality_2, create a new dictionary and store the updates you want to keep there instead.
CLICK HERE to find out more related problems solutions.