Python Tip: To count the number of occurrences within a Python dictionary, use Counter from the collections module.
Heres an example 👇
from collections import Counter
devices_vendors = {
'device001': 'Cisco',
'device002': 'Juniper',
'device003': 'Cisco',
'device004': 'Arista',
'device005': 'Cisco'
}
vendor_counts = Counter(devices_vendors.values())
print(vendor_counts)
# Output:
# Counter({'Cisco': 3, 'Juniper': 1, 'Arista': 1})