I have a data set of lists of varying length containing integers in range 0-4 like this:
a = [0, 1, 1, 2, 4, 3, 2]
b = [1, 3, 2, 3, 2]
c = [2, 4, 0, 4, 1, 3, 1, 4]
d = ...
for which I determine frequency of elements using a simple function:
def getFreq(group):
freq = [0] * 5
for item in group:
for i in range(5):
if (item == i):
freq[i] += 1
return freq
that I run for all lists using a for loop like this:
all_groups = [a, b, c]
for group in all_groups:
getFreq(group)
How do I store the resulting lists automatically so that I can do further operations/comparisons later? Based on comments it appears it is best to use a dictionary. How do I cycle through dictionary keys in the for loop so that the results of each instance of the function are saved to a different key?