product_of_elems = functools.reduce(<spanclass="hljs-keyword">lambda</span> out, x: out * x, <collection>)
product_of_elems = functools.reduce(<spanclass="hljs-keyword">lambda</span> out, x: out * x, <collection>)
list_of_chars = list(<str>)
list_of_chars = list(<str>)
</code></pre>
</code></pre>
<ul>
<li><strong>Check out module <ahref="#operator">operator</a> for alternative versions of examples.</strong></li>
</ul>
<pre><codeclass="python language-python hljs"><int> = <list>.count(<el>) <spanclass="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
<pre><codeclass="python language-python hljs"><int> = <list>.count(<el>) <spanclass="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
index = <list>.index(<el>) <spanclass="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
index = <list>.index(<el>) <spanclass="hljs-comment"># Returns index of first occurrence or raises ValueError.</span>
<list>.insert(index, <el>) <spanclass="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
<list>.insert(index, <el>) <spanclass="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
@ -1853,14 +1856,14 @@ lock.release()
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op
<pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op