Mac,<div><br></div><div>this is what I get:</div><div><br></div><div><div>&gt;&gt;&gt; for prod in itertools.product(&#39;ABC&#39;, 2):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>print(prod)</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>Traceback (most recent call last):</div><div>  File &quot;&lt;pyshell#34&gt;&quot;, line 1, in &lt;module&gt;</div><div>    for prod in itertools.product(&#39;ABC&#39;, 2):</div>
<div>TypeError: &#39;int&#39; object is not iterable</div></div><div><br></div><div><br></div><div>hmm, what might be that &#39;int&#39; object? 2?</div><div><br></div><div><br><div class="gmail_quote">2010/7/28 ZUXOXUS <span dir="ltr">&lt;<a href="mailto:zuxoxus@gmail.com">zuxoxus@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div>Sharp thanks, but:</div><div><br></div><div>I try to reproduce the example from the table, but:</div><div><br></div>
<div>&gt;&gt;&gt; import itertools</div><div>&gt;&gt;&gt; combinations(&#39;ABC&#39;, 2)</div><div>Traceback (most recent call last):</div>
<div>  File &quot;&lt;pyshell#27&gt;&quot;, line 1, in &lt;module&gt;</div><div>    combinations(&#39;ABC&#39;, 2)</div><div>NameError: name &#39;combinations&#39; is not defined</div><div>&gt;&gt;&gt; </div><div><br></div>

<div>If im not mistaken, it should return AB, AC, BA, etc.</div><div><br></div><div>I&#39;m using Python 3.1</div><div><br></div><br><div class="gmail_quote">2010/7/28 Mark Lawrence <span dir="ltr">&lt;<a href="mailto:breamoreboy@yahoo.co.uk" target="_blank">breamoreboy@yahoo.co.uk</a>&gt;</span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>On 27/07/2010 23:20, ZUXOXUS wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
Hi all pythoners<br>
<br>
I&#39;ve got a probably easy to answer question.<br>
<br>
Say I&#39;ve got a collections of strings, e.g.: &#39;man&#39;, &#39;bat&#39;, &#39;super&#39;, &#39;ultra&#39;.<br>
<br>
They are in a list, or in a sequence or whatever, say a bag of words<br>
<br>
And now I want to know how many couples I can do with them, and I want the<br>
program to show me the actual couples: &#39;manman&#39;, &#39;manbat&#39;, &#39;mansuper&#39;,<br>
&#39;manultra&#39;, &#39;batbat&#39;, &#39;batman&#39;, &#39;batsuper&#39;, etc.<br>
<br>
But hey, why building up new words from just two strings? I also want to<br>
know the possible combinations of three words, four words, and perhaps, why<br>
not, five words.<br>
<br>
So, is it easy to do?<br>
<br>
Sorry, I&#39;m new in programing, and am probably far from being a math-master<br>
<br>
I&#39;m clueless, I think probably the code have some FOR I IN SEQUENCE... but<br>
then what? I don&#39;t know how to say: take every element and paste it to<br>
another one from the bag, and with another one, and with another one,...<br>
<br>
If it&#39;s too complex, I dont need the whole code recipe, just need some<br>
clues, or perhaps a useful link<br>
<br>
Thank you very much in advance!<br>
<br></div></div><div>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></blockquote>
<br>
The lazy way.<div><br>
<a href="http://docs.python.org/library/itertools.html" target="_blank">http://docs.python.org/library/itertools.html</a><br></div>
Look for combinations().<br>
<br>
HTH.<br><font color="#888888">
<br>
Mark Lawrence.</font><div><div></div><div><br>
<br>
<br>
_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br></div>