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

lina lina.lastname at gmail.com
Fri Oct 7 14:19:27 CEST 2011


On Fri, Oct 7, 2011 at 6:25 PM, Dave Angel <d at davea.name> wrote:

> On 10/07/2011 06:06 AM, Alan Gauld wrote:
>
>> On 07/10/11 09:08, lina wrote:
>> <snip>
>>
>>      summary=[]
>>>     for a,b in zip(results['E'],results['B'])**:
>>>         summary.append(a+b)
>>>
>>
>> I don't know why this gives a key error on 'E' (which basically means that
>> there is no key 'E') since the code above should guarantee that it exists.
>> Odd. I'm also not sure why the error occurs after it prints summary. Are you
>> sure the output is in the sequence you showed in your message?
>>
>>  One simple explanation:  it continued on to the next file, which has
> neither "E" nor "B" in it.
>
>
>
>
The final results got "6" summary out, which I only expect one.
and how can I output the summary, in the wrong situation, let it \n ?


$ more try.txt
[1, 0, 1, 0, 1, 0][1, 0, 1, 0, 1, 0][1, 0, 1, 0, 1, 0][1, 0, 1, 0, 1, 0][1,
0, 1
, 0, 1, 0][1, 0, 1, 0, 1, 0]



> --
>
> DaveA
>
>
> ______________________________**_________________
> 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>
>



-- 
Best Regards,

lina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111007/dded4f3f/attachment.html>


More information about the Tutor mailing list