Hi,<br>
<br>
I am not sure what 'random' does (what package is it from?), but <br><br><div style="margin-left: 40px;">list=['1','2','3']<br>slist=','.join(list)<br></div><br>works, while<br><br><div style="margin-left: 40px;">list=[1,2,3]
<br>slist=','.join(list)<br></div><br>does not.&nbsp; It appears 'join' only works on lists (and maybe tuples?) of string objects and the list must be passed in as an argument.&nbsp; Try translating your list into a list of string representation of numbers and then using join.
<br><br>Hope this is a useful clue,<br>-Jason<br><br><div><span class="gmail_quote">On 11/27/06, <b class="gmail_sendername">Moedeloos Overste</b> &lt;<a href="mailto:kloosterjunkie@hotmail.com">kloosterjunkie@hotmail.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I'm trying to use the join() method on a list to be able to store the
<br>contents of that list in a file. Basically I want the contents of the list<br>stored without the []. I've tried numerous ways of using the join() method,<br>but they all return errors. I've tried using the tutorial and documentation
<br>on this one but still can't work it out.<br><br>errors: TypeError: sequence item 0: expected string, int found<br><br><br><br>code:<br>LotNumbers = random.sample(range(1,45), 6) #random numbers from range into<br>list)
<br>&nbsp;&nbsp;&nbsp;&nbsp;','.join()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#?what's the<br>correct syntax?<br>&nbsp;&nbsp;&nbsp;&nbsp;fout = open(&quot;draw__output.dat&quot;, &quot;a&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;fout.write(LotNumbers)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #writing string to
<br>file<br>&nbsp;&nbsp;&nbsp;&nbsp;fout.close()<br>&nbsp;&nbsp;&nbsp;&nbsp;vDraws = vDraws - 1<br><br>Can someone show me the correct way to use the join() method in this case?<br><br>Many thanks,<br><br>Robert<br><br>_________________________________________________________________
<br>De makers van Hotmail hebben groot nieuws! Meer weten? Klik hier!<br><a href="http://imagine-windowslive.com/mail/launch/default.aspx?Locale=nl-nl">http://imagine-windowslive.com/mail/launch/default.aspx?Locale=nl-nl</a>
<br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor
</a><br></blockquote></div><br>