Is there any efficient implementation for iterating over a list and updating the corresponding value in a dictionary? What I want to do is shown in the code below: