I have two dictionaries:
dict1 = agent_id:agent_email
dict2 = user_id:agent_id
I want to create a dictionary:
agent_id: list of user_ids associated with agent_id
How do I search dict2 for each agent_id from dict1 and return the associated key? I've been told that creating a list of keys and then searching is very slow. Is there a faster way?
The question suggested as a dupe does not tell me what I'd like to know. I'm trying to search all the values without creating a separate list. Also, once I have the value, how to I get the corresponding key?
EDIT All the information I need is in dict2. The question is how do I get at it. Each agent_id is associated with multiple user_id's. I want to create a dict that looks like this:
{agent_id_1:(user_id_1, user_id_2, user_id_45), agent_id_2:(user_id_987), agent_id_3:(user_id_10, user_id_67)...etc}
based on one of the answers, I'm looking into created a 'reverse dict'. I'm don't really understand this yet, as the values in dict2 (the agent_ids) are not unique. Is this the way to go?