def frequencies(seq):
 d = collections.defaultdict(int)
 for item in seq:
  d[item] += 1
 return dict(d)

def frequencies ( seq ) : d = collections . defaultdict ( int ) for item in seq : d [ item ] += 1 return dict ( d )
find number of occurrences of each value in seq .