From 6412d9300729f25983335fed87cb781fc6355182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 17 Jan 2020 20:44:34 +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 02613f1..6867313 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,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. {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. +{k: v for k, v in .items() if k in keys} # Returns a dictionary, filtered by keys. ``` ### Counter diff --git a/index.html b/index.html index 58043fa..1d3d215 100644 --- a/index.html +++ b/index.html @@ -273,7 +273,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. {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. +{k: v for k, v in <dict>.items() if k in keys} # Returns a dictionary, filtered by keys.

Counter

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