From 339eb47a0226728697e07103c61fae83513807bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 10 Dec 2019 18:24:21 +0100 Subject: [PATCH] Dictionary --- README.md | 4 ++-- index.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01a1006..7a3c684 100644 --- a/README.md +++ b/README.md @@ -86,9 +86,9 @@ value = .setdefault(key, default=None) # Returns and writes default if ``` ```python -value = .pop(key) # Removes item or raises KeyError. .update() # Adds items. Replaces ones with matching keys. -[k for k, v in .items() if v == value] # Returns list of keys that point to the value. +value = .pop(key) # Removes item or raises KeyError. +{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 dictionary filtered by keys. ``` diff --git a/index.html b/index.html index 6e21009..581941c 100644 --- a/index.html +++ b/index.html @@ -270,9 +270,9 @@ value = <dict>.setdefault(key, default=None# Creates a dict from two collections. <dict> = dict.fromkeys(keys [, value]) # Creates a dict from collection of keys. -
value = <dict>.pop(key)                         # Removes item or raises KeyError.
-<dict>.update(<dict>)                           # Adds items. Replaces ones with matching keys.
-[k for k, v in <dict>.items() if v == value]    # Returns list of keys that point to the value.
+
<dict>.update(<dict>)                           # Adds items. Replaces ones with matching keys.
+value = <dict>.pop(key)                         # Removes item or raises KeyError.
+{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 dictionary filtered by keys.
 

Counter

>>> from collections import Counter