On Sat, Oct 8, 2011 at 6:27 PM, Alan Gauld <alan.ga...@btinternet.com>wrote:

> On 08/10/11 04:34, lina wrote:
>
>          print(summary)   ### output is [1,3,5,6]
>>         summary='\n'.join(str(summary)**.split(','))
>>
>
> This line is wrong.
> This is converting summary to a string -> '[1,3,5,6]'
> Then splitting by commas to create a new list -> [ '[1', '3', '5', 6]' ]
> Notice the first and last elements have the []
> Then it joins then into a string using \n as seperators.
>
> What you want, I think, is to join the original list
> with spaces(and maybe add a newline for writing to file)
>
>
> summary = ' '.join(summary) + \n

sorry, just correct forget testing,

Traceback (most recent call last):
  File "counter-vertically-WORKING.py", line 32, in <module>
    new_summary=''.join((summary[1:-3]))+"\n"
TypeError: sequence item 0: expected str instance, int found

so
        new_summary=''.join(str(summary[1:-3]))+"\n"

but the results seems as summary[1:-3], still has [ ] and not in new lines.

Thanks,



>
>
>          with open(base+OUTFILEEXT,"w") as f:
>>             f.write(str(summary))
>>
>
> HTH,
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ______________________________**_________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to