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))}