From fd37e55063ae5451e07a6203c274abb61bd3aaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 20 Feb 2024 11:05:21 +0100 Subject: [PATCH] Dictionary --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4c571e5..009a83d 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ value = .setdefault(key, default=None) # Returns and writes default if .update() # Adds items. Replaces ones with matching keys. value = .pop(key) # Removes item or raises KeyError if missing. {k for k, v in .items() if v == value} # Returns set of keys that point to the value. -{k: v for k, v in .items() if k in keys} # Returns a dictionary, filtered by keys. +{k: v for k, v in .items() if k in keys} # Filters the dictionary by keys. ``` ### Counter diff --git a/index.html b/index.html index c0eaea6..31122ca 100644 --- a/index.html +++ b/index.html @@ -147,7 +147,7 @@ value = <dict>.setdefault(key, default=None<dict>.update(<dict>) # Adds items. Replaces ones with matching keys. value = <dict>.pop(key) # Removes item or raises KeyError if missing. {k for k, v in <dict>.items() if v == value} # Returns set of keys that point to the value. -{k: v for k, v in <dict>.items() if k in keys} # Returns a dictionary, filtered by keys. +{k: v for k, v in <dict>.items() if k in keys} # Filters the dictionary by keys.

Counter

>>> from collections import Counter
 >>> colors = ['blue', 'blue', 'blue', 'red', 'red']