efficient way to count the element in a dictionary in python using a loop,{x[0]: len(list(x[1])) for x in itertools.groupby(sorted(mylist))}