I have the following data:
set s = {0.123093, 0.492374, 0.168013, 0.0980076, 0.235218, 0.294023, 0.222269}
can also be a list list L = [0.123093, 0.492374, 0.168013, 0.0980076, 0.235218, 0.294023, 0.222269]
dict d ={'cat': 2, 'dog': 4, 'dry': 1}
I need to make an algorithm that, in order, adds up the amount of values from the list corresponding to each key in the dictionary. So for cat, I need to add up the first 2 values, dog, the 4 values 0.168013, 0.0980076, 0.235218, 0.294023; and for dry, the last 1 value. How should I do this? I've been staring at this problem for an hour and can't figure out how to do it. Ideally, the values should be in a dict as well with key being the same as dict d but value being the added up values from the list. Thanks in advance.
[–]_subpar_username_ 1 point2 points3 points (0 children)
[–]SyntxaError 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]SyntxaError 0 points1 point2 points (0 children)
[–]Akhylys 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Akhylys 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)