Browse Source

List

pull/36/head
Jure Šorn 5 years ago
parent
commit
d38a6257f1
2 changed files with 4 additions and 2 deletions
  1. 3
      README.md
  2. 3
      index.html

3
README.md

@ -55,7 +55,8 @@ list_of_chars = list(<str>)
```
```python
index = <list>.index(<el>) # Returns first index of item or raises ValueError.
<bool> = <el> in <collection> # For dictionary it checks if key exists.
index = <list>.index(<el>) # Returns index of first occurrence or raises ValueError.
<list>.insert(index, <el>) # Inserts item at index and moves the rest to the right.
<el> = <list>.pop([index]) # Removes and returns item at index or from the end.
<list>.remove(<el>) # Removes first occurrence of item or raises ValueError.

3
index.html

@ -237,7 +237,8 @@ flatter_list = list(itertools.chain.from_iterable(&lt;list&gt;))
product_of_elems = functools.reduce(<span class="hljs-keyword">lambda</span> out, x: out * x, &lt;collection&gt;)
list_of_chars = list(&lt;str&gt;)
</code></pre>
<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>
<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>
index = &lt;list&gt;.index(&lt;el&gt;) <span class="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
&lt;list&gt;.insert(index, &lt;el&gt;) <span class="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
&lt;el&gt; = &lt;list&gt;.pop([index]) <span class="hljs-comment"># Removes and returns item at index or from the end.</span>
&lt;list&gt;.remove(&lt;el&gt;) <span class="hljs-comment"># Removes first occurrence of item or raises ValueError.</span>

Loading…
Cancel
Save