I have a Python problem that can be solved with multiple nested for
loops but I was wondering if there is an easier way to solve this, maybe by adding list items together and dropping duplicates.
My list looks like this:
main_list = [["[email protected]", "Administration", "100"],
["[email protected]", "Testing", "30"],
["[email protected]", "Development", "45"],
["[email protected]", "Development", "90"],
["[email protected]", "Development", "35"],
["[email protected]", "Development", "400"],
["[email protected]", "Administration", "95"],
["[email protected]", "Testing", "200"]]
I need to merge the email address and category (the first two list elements) and add the duplicate 3rd entries together.
So [user2, development] goes from:
["[email protected]", "Development", "45"],
["[email protected]", "Development", "90"],
["[email protected]", "Development", "35"],
to:
["[email protected]", "Development", "170"]
It this possible with list manipulation?
Thank you!