your last for iterater maybe should like this: for key,values in messages: if max is None or values>max: sender=key max=values
在 2012-10-5,1:13,tutor-requ...@python.org 写道: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Hello Can someone looked at my problem? stuck (Palice Fan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 2 Oct 2012 23:39:00 -0400 > From: Palice Fan <magicwizards...@gmail.com> > To: tutor@python.org > Subject: [Tutor] Hello Can someone looked at my problem? stuck > Message-ID: > <CAEqgQa4Aup6t+f237cfvkjkf54XRv2=pymuxjqgzzka8gme...@mail.gmail.com> > Content-Type: text/plain; charset="windows-1252" > > Hello > i got stuck with the last bit of my programming practice. > Can somebody help me? > Write a program to read through a mail log, and figure out who had the most > messages in the file. The program looks for ?From? lines and takes the > second parameter on > those lines as the person who sent the mail. > The program creates a Python dictionary that maps the sender?s address to > the total number of > messages for that person. > After all the data has been read the program looks through the dictionary > using a maximum loop > (see Section 5.7.2) to find who has the most messages and how many messages > the person has. > > Enter a file name: mbox-short.txt > c...@iupui.edu :5 > Enter a file name: mbox.txt > zq...@umich.edu :195 > > Instead of printing off a number beside the email, i got another email and > i dont know how to fix it. > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://mail.python.org/pipermail/tutor/attachments/20121002/3fd4d310/attachment.html> > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: 9.4 stuck.png > Type: image/png > Size: 67410 bytes > Desc: not available > URL: > <http://mail.python.org/pipermail/tutor/attachments/20121002/3fd4d310/attachment.png> > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > ------------------------------ > > End of Tutor Digest, Vol 104, Issue 24 > ************************************** > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor