I have a list of tuples holding ('Day of Week', n)
as follows:
[('Wed', 1), ('Wed', 1), ('Thu', 1), ('Thu', 0), ('Tue', 0), ('Mon', 0), ('Sun', 0), ('Sat', 0),
('Fri', 0)]
I want to produce the following output, a list of tuples holding ('Day of Week', sum_n)
, where sum_n
is the sum of all the corresponding n
values in my initial list. Note that the elements should be in order of weekday.
[('Wed', 2), ('Thu', 1), ('Tue', 0), ('Mon', 0), ('Sun', 0), ('Sat', 0), ('Fri', 0)]
How can this be achieved?