On Fri, Oct 7, 2011 at 6:25 PM, Dave Angel <d...@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@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
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor