Skip to content

Commit d38a625

Browse files
committed
List
1 parent ee3fd66 commit d38a625

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ list_of_chars = list(<str>)
5555
```
5656

5757
```python
58-
index = <list>.index(<el>) # Returns first index of item or raises ValueError.
58+
<bool> = <el> in <collection> # For dictionary it checks if key exists.
59+
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.
6162
<list>.remove(<el>) # Removes first occurrence of item or raises ValueError.

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ <h2 id="list"><a href="#list" name="list">#</a>List</h2>
237237
product_of_elems = functools.reduce(<span class="hljs-keyword">lambda</span> out, x: out * x, &lt;collection&gt;)
238238
list_of_chars = list(&lt;str&gt;)
239239
</code></pre>
240-
<pre><code class="python language-python hljs">index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns first index of item or raises ValueError.</span>
240+
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;el&gt; <span class="hljs-keyword">in</span> &lt;collection&gt; <span class="hljs-comment"># For dictionary it checks if key exists.</span>
241+
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
241242
&lt;list&gt;.insert(index, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
242243
&lt;el&gt; = &lt;list&gt;.pop([index]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
243244
&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)