Skip to content

Commit 6412d93

Browse files
committed
Dictionary
1 parent 1afe72f commit 6412d93

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ value = <dict>.setdefault(key, default=None) # Returns and writes default if
8989
<dict>.update(<dict>) # Adds items. Replaces ones with matching keys.
9090
value = <dict>.pop(key) # Removes item or raises KeyError.
9191
{k for k, v in <dict>.items() if v == value} # Returns set of keys that point to the value.
92-
{k: v for k, v in <dict>.items() if k in keys} # Returns dictionary filtered by keys.
92+
{k: v for k, v in <dict>.items() if k in keys} # Returns a dictionary, filtered by keys.
9393
```
9494

9595
### Counter

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
<pre><code class="python language-python hljs">&lt;dict&gt;.update(&lt;dict&gt;) <span class="hljs-comment"># Adds items. Replaces ones with matching keys.</span>
274274
value = &lt;dict&gt;.pop(key) <span class="hljs-comment"># Removes item or raises KeyError.</span>
275275
{k <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> &lt;dict&gt;.items() <span class="hljs-keyword">if</span> v == value} <span class="hljs-comment"># Returns set of keys that point to the value.</span>
276-
{k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> &lt;dict&gt;.items() <span class="hljs-keyword">if</span> k <span class="hljs-keyword">in</span> keys} <span class="hljs-comment"># Returns dictionary filtered by keys.</span>
276+
{k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> &lt;dict&gt;.items() <span class="hljs-keyword">if</span> k <span class="hljs-keyword">in</span> keys} <span class="hljs-comment"># Returns a dictionary, filtered by keys.</span>
277277
</code></pre>
278278
<div><h3 id="counter">Counter</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> Counter
279279
<span class="hljs-meta">&gt;&gt;&gt; </span>colors = [<span class="hljs-string">'blue'</span>, <span class="hljs-string">'red'</span>, <span class="hljs-string">'blue'</span>, <span class="hljs-string">'red'</span>, <span class="hljs-string">'blue'</span>]

0 commit comments

Comments
 (0)