Browse Source

List

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

1
README.md

@ -55,6 +55,7 @@ list_of_chars = list(<str>)
```
```python
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
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.

3
index.html

@ -249,7 +249,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 index of first occurrence or raises ValueError.</span>
<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>
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