<br><br><div class="gmail_quote">On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld <span dir="ltr"><<a href="mailto:alan.gauld@btinternet.com">alan.gauld@btinternet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 08/10/11 04:34, lina wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
print(summary) ### output is [1,3,5,6]<br>
summary='\n'.join(str(summary)<u></u>.split(','))<br>
</blockquote>
<br></div>
This line is wrong.<br>
This is converting summary to a string -> '[1,3,5,6]'<br>
Then splitting by commas to create a new list -> [ '[1', '3', '5', 6]' ]<br>
Notice the first and last elements have the []<br>
Then it joins then into a string using \n as seperators.<br>
<br>
What you want, I think, is to join the original list<br>
with spaces(and maybe add a newline for writing to file)<br></blockquote><div>You are right! <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
summary = ' '.join(summary) + \n<div class="im"><br>
<br></div></blockquote><div>Just correct. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
with open(base+OUTFILEEXT,"w") as f:<br>
f.write(str(summary))<br>
</blockquote>
<br></div>
HTH,</blockquote><div><br>Thanks, it's helpful. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im"><br>
<br>
-- <br>
Alan G<br>
Author of the Learn to Program web site<br>
<a href="http://www.alan-g.me.uk/" target="_blank">http://www.alan-g.me.uk/</a><br>
<br></div><div><div></div><div class="h5">
______________________________<u></u>_________________<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/<u></u>mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br>