I'm looping through steps in a dictionary and pulling out a contact phone number and an id for each step, and put these as key/value pairs into a new dict: contacts
contacts = {}
for execution_step in execution_steps["steps"]:
main_execution_context = get_execution_context(execution_step["url"])
contact_phone = main_execution_context["contact"]
id = main_execution_context["id"]
contacts[contact_phone] = id
Where there are duplicates of contact_phone
i.e. the key already exists, is it possible to append the value pair (id
) onto the existing value, thus creating a list of id's associated with the same phone number?