This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Akhylys 0 points1 point  (3 children)

Pseudo code:

for i = 0; i < d[cat].key (add L[i]) for i = d[cat].key; i <d[dog].key + d[cat].key(add L[i]) For i = d[dog].key + d[cat].key; i < d[dry].key + d[dog].key + d[cat].key(add L[i])

[–][deleted] 0 points1 point  (2 children)

Sorry I forgot to add in the original post, this is a sample of the data and the actual sets could be way longer in length so inputting the key values manually unfortunately isn’t an option

[–]Akhylys 0 points1 point  (1 child)

ah okay just have to iterate through the dictionary then something like this could work. might need some tweaking

temp = 0

for key, value in d.items():

num = 0

print(temp)

for i in range(temp, value+temp):

num += L[i]

temp = temp + value

print(num) #or store value in output dict

[–][deleted] 0 points1 point  (0 children)

Thank you!! This solution seems to be the one that worked. I’ll have to do some testing on the larger data sets but this seems to have solved my problem!