python update nested dictionary in loop