Skip to content

Commit 339eb47

Browse files
committed
Dictionary
1 parent f21a0a4 commit 339eb47

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ value = <dict>.setdefault(key, default=None) # Returns and writes default if
8686
```
8787

8888
```python
89-
value = <dict>.pop(key) # Removes item or raises KeyError.
9089
<dict>.update(<dict>) # Adds items. Replaces ones with matching keys.
91-
[k for k, v in <dict>.items() if v == value] # Returns list of keys that point to the value.
90+
value = <dict>.pop(key) # Removes item or raises KeyError.
91+
{k for k, v in <dict>.items() if v == value} # Returns set of keys that point to the value.
9292
{k: v for k, v in <dict>.items() if k in keys} # Returns dictionary filtered by keys.
9393
```
9494

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@
270270
&lt;dict&gt; = dict(zip(keys, values)) <span class="hljs-comment"># Creates a dict from two collections.</span>
271271
&lt;dict&gt; = dict.fromkeys(keys [, value]) <span class="hljs-comment"># Creates a dict from collection of keys.</span>
272272
</code></pre>
273-
<pre><code class="python language-python hljs">value = &lt;dict&gt;.pop(key) <span class="hljs-comment"># Removes item or raises KeyError.</span>
274-
&lt;dict&gt;.update(&lt;dict&gt;) <span class="hljs-comment"># Adds items. Replaces ones with matching keys.</span>
275-
[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 list of keys that point to the value.</span>
273+
<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>
274+
value = &lt;dict&gt;.pop(key) <span class="hljs-comment"># Removes item or raises KeyError.</span>
275+
{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>
276276
{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>
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

0 commit comments

Comments
 (0)