Skip to content

Commit 399ff13

Browse files
committed
List
1 parent bbaef7f commit 399ff13

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ list_of_chars = list(<str>)
5555
```
5656

5757
```python
58+
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
5859
index = <list>.index(<el>) # Returns index of first occurrence or raises ValueError.
5960
<list>.insert(index, <el>) # Inserts item at index and moves the rest to the right.
6061
<el> = <list>.pop([index]) # Removes and returns item at index or from the end.

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@
249249
product_of_elems = functools.reduce(<span class="hljs-keyword">lambda</span> out, x: out * x, &lt;collection&gt;)
250250
list_of_chars = list(&lt;str&gt;)
251251
</code></pre>
252-
<pre><code class="python language-python hljs">index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
252+
<pre><code class="python language-python hljs">&lt;int&gt; = &lt;list&gt;.count(&lt;el&gt;) <span class="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
253+
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
253254
&lt;list&gt;.insert(index, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
254255
&lt;el&gt; = &lt;list&gt;.pop([index]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
255256
&lt;list&gt;.remove(&lt;el&gt;) <span class="hljs-comment"># Removes first occurrence of item or raises ValueError.</span>

0 commit comments

Comments
 (0)