dictionary counts of unique values code example
Example 1: find number of unique keys in the dictionary
# find number of unique keys in the dictionary
keys_num = len(dictionary.keys())
Example 2: count unique values in python
aa="XXYYYSBAA"
bb=dict(zip(list(aa),[list(aa).count(i) for i in list(aa)]))
print(bb)
# output:
# {'X': 2, 'Y': 3, 'S': 1, 'B': 1, 'A': 2}