I am a python beginner and I am working on a small project but I can't get the output wanted.
This is the entry value that I have, I have to keep only the email's and associate them with the project without duplicated values. This my entry:
my_dictionnary = [
{
"email": ["email1", "email2"],
"project":"projet1",
"project_name":"Project1"
},
{
"email": ["email1", "email2"],
"project":"projet2",
"project_name":"Project2"
},
{
"email": ["email2"],
"project":"projet3",
"project_name":"Project3"
}
]
I would like to create the ouput as follows:
my_dictionnary_parsed = {
"email2": ["projet1", "projet2", "projet3"],
"email1": ["projet1", "projet2"]
}
I have the following function:
def formating_email(list_of_email):
dictionnary={}
for email_data in list_of_email_data:
for cp in email_data['cp_related']:
print(cp,email_data['ticket_related_project'])
dictionnary[cp] = email_data
But the values keep overriding...