[Tutor] a quick Q: how to use for loop to read a series of files with .doc end

lina lina.lastname at gmail.com
Sat Oct 8 18:20:03 CEST 2011


On Sat, Oct 8, 2011 at 10:50 PM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> On 08/10/11 11:27, Alan Gauld wrote:
>
>  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
>>
>
> But you need to make the original items strings first
> so it should be:
>
>  summary = ' '.join( map(str,summary) ) + \n
>

    new_summary=' '.join( map(str,summary) ) + \n
                                                ^
SyntaxError: unexpected character after line continuation character

so I added it as

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

but each one in summary does not show in new line.

new_summary='\n'.join(map(str,summary[1:-3]))

This one works,

>
> Sorry about that,


Thanks for your suggestions.


>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111009/a78d6ef5/attachment.html>


More information about the Tutor mailing list