update and pop in python dictionary