Unnamed
public python v1 · immutable>>> d{1: 4, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 3, 9: 1}>>> l = ['x', 'x', 'x', 'y', 'y', None, None, None]>>> d = {}>>> for i in set(l):... d[i] = l.count(i)...>>> d{'y': 2, 'x': 3, None: 3}>>> d{1: 4, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 3, 9: 1}>>> l = ['x', 'x', 'x', 'y', 'y', None, None, None]>>> d = {}>>> for i in set(l):... d[i] = l.count(i)...>>> d{'y': 2, 'x': 3, None: 3}