There is a list of email id and need to add key "email" to every elements in a list. Email list:
user = ["[email protected]","[email protected]"]
Here email key is to be added and output should be as. [{'email': '[email protected]'}, {'email': '[email protected]'}]
For this,
email_object = {}
email_list = []
user = ["[email protected]","[email protected]"]
for i in user:
email_object["email"] = i
email_list.append(email_object)
print(email_list)
Result:
[{'email': '[email protected]'}, {'email': '[email protected]'}]
Only last email address in a list is shown in a result. How to show output result as :
[{'email': '[email protected]'}, {'email': '[email protected]'}]