<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.product(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-string">'abc'</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a x x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b x x x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># c x x x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.combinations(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a . x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># b . . x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.combinations_with_replacement(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a x x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b . x x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># c . . x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.permutations(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a . x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b x . x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'b'</span>)] <spanclass="hljs-comment"># c x x .</span>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.product(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-string">'abc'</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a x x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b x x x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># c x x x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.combinations(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a . x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># b . . x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.combinations_with_replacement(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a x x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b . x x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'c'</span>)] <spanclass="hljs-comment"># c . . x</span>
</code></pre>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>it.permutations(<spanclass="hljs-string">'abc'</span>, <spanclass="hljs-number">2</span>) <spanclass="hljs-comment"># a b c</span>
[(<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'b'</span>), (<spanclass="hljs-string">'a'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># a . x x</span>
(<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'b'</span>, <spanclass="hljs-string">'c'</span>), <spanclass="hljs-comment"># b x . x</span>
(<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'a'</span>), (<spanclass="hljs-string">'c'</span>, <spanclass="hljs-string">'b'</span>)] <spanclass="hljs-comment"># c x x .</span>