Re: [Tutor] AttributeError,

2015-08-12 Thread Ltc Hotspot
rds, Hal On Tue, Aug 11, 2015 at 8:32 PM, Steven D'Aprano wrote: > On Tue, Aug 11, 2015 at 07:38:21PM -0700, Ltc Hotspot wrote: >> Steven, >> >> Visit the URL links below to view the latest revised code: > > I don't think so. I don't have access to the web

Re: [Tutor] AttributeError,

2015-08-12 Thread Ltc Hotspot
/ozzmffy Thanks, Hal On Tue, Aug 11, 2015 at 7:01 PM, Steven D'Aprano wrote: > On Tue, Aug 11, 2015 at 04:24:39PM -0700, Ltc Hotspot wrote: > > Hi Everyone, > > > > Why is there an AttributeError, line 12, below : 'tuple' object has no > > attribute 'so

[Tutor] AttributeError,

2015-08-11 Thread Ltc Hotspot
Hi Everyone, Why is there an AttributeError, line 12, below : 'tuple' object has no attribute 'sort'? count = dict() fname = raw_input("Enter file name: ")# handle = open (fname, 'r')# for line in handle: if line.startswith("From "): address = line.split()[5] line = line.rstri

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Ltc Hotspot
On 07/08/2015 01:30, Ltc Hotspot wrote: > >> Mark, >> >> I'm following the instructor's video exercise, available at >> https://www.youtube.com/watch?v=3cwXN5_3K6Q. >> >> View attached screen shot file, image file shows a copy of the >> counte

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Ltc Hotspot
ove? Question2: dict maps strings into keys and values? Hal On Thu, Aug 6, 2015 at 11:35 PM, Alan Gauld wrote: > On 07/08/15 01:15, Ltc Hotspot wrote: > >> Question1: How type of argument should I use for dict, i.e.,user argument >> or list argument. >> >> Read ca

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
6, 2015 at 4:53 PM, Mark Lawrence wrote: > On 06/08/2015 20:05, Ltc Hotspot wrote: > >> On my breath and soul, I did: >> >> Counter objects have a dictionary interface except that they return a zero >> count for missing items instead of raising a KeyError >> <

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
the revised code? Revised code is available at https://gist.github.com/ltc-hotspot/00fa77ca9b40c0a77170 Regards, Hal On Thu, Aug 6, 2015 at 4:20 PM, Alan Gauld wrote: > On 07/08/15 00:11, Ltc Hotspot wrote: > >> Questions(1):Why does print line, prints blank space; and, (2) print >> addr

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
On Thu, Aug 6, 2015 at 3:00 PM, Alan Gauld wrote: > On 06/08/15 19:30, Ltc Hotspot wrote: > > I moved counter outside the loop and below dict, maxval = None >> maxkee = None are both positioned outside the loop. >> > > You moved counter but it is still a dict() and

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
am']) On Thu, Aug 6, 2015 at 11:59 AM, Mark Lawrence wrote: > On 06/08/2015 18:17, Ltc Hotspot wrote: > >> On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence >> wrote: >> >> On 06/08/2015 05:22, Ltc Hotspot wrote: >>> >>> Please don't top post he

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Mark, Visit the following URL link to view a captured copy of the latest code revision, available at http://tinyurl.com/nvzdw8k Regards, Hal On Thu, Aug 6, 2015 at 10:17 AM, Ltc Hotspot wrote: > > > On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence > wrote: > >> On 06/08/20

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
x27; is not defined Regards, Hal On Thu, Aug 6, 2015 at 2:47 AM, Alan Gauld wrote: > On 06/08/15 03:27, Ltc Hotspot wrote: > >> The output as reported by the latest code revision: c...@iupui.edu >> <mailto:c...@iupui.edu> 1← Mismatch >> >> Looks like python

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence wrote: > On 06/08/2015 05:22, Ltc Hotspot wrote: > > Please don't top post here, it makes following long threads difficult. > > Mark, >> >> Replace count[address]= count.get(address,0) +1 with c = >> Coun

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? Regards, Hal On Wed, Aug 5, 2015 at 9:03 PM, Mark Lawrence wrote: > On 05/08/2015 23:58, Ltc Hotspot wrote: > >> Hi Mark, >> >> Address identifies the email address with

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
maxkee = None for kee, val in count.items(): maxval = val maxkee = kee print address, val Hal On Wed, Aug 5, 2015 at 6:21 PM, Alan Gauld wrote: > On 05/08/15 23:58, Ltc Hotspot wrote: > > fname = raw_input("Enter file name: ") >> handle = open (fname,

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
xkee = kee print address, val On Wed, Aug 5, 2015 at 4:11 PM, Alan Gauld wrote: > On 05/08/15 15:15, Ltc Hotspot wrote: > > Raw data code reads: >> > > Being picky here but data and code are very different > things (in most languages at least) and what you have > below

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Ltc Hotspot
Hi Mark, Address identifies the email address with the maximum number of sends: c...@iupui.edu. Secondly, we are missing a count on the number of messages sent by c...@iupui.edu, i.e., 5. Thirdly, maxval 'none' is not defined on line # 24 Questions: How do we define the value of none for the k

[Tutor] Dictionary Issue

2015-08-05 Thread Ltc Hotspot
Hi everyone: I want to write a python program that reads through the data file of mbox-short.txt.Mbox-short.txt, i.e., download is available at http://www.py4inf.com/code/mbox-short.txt. Secondly, I want for python to figure out who sent the greatest number of mail messages. The output should r

Re: [Tutor] String Attribute

2015-08-02 Thread Ltc Hotspot
edu'] ← Mismatch There were 54 lines in the file with From as the first word Desired output: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu c...@iupui.edu c...@iupui.edu gsil...@umich.edu gsil...@umich.edu zq...@umich.ed

Re: [Tutor] String Attribute

2015-08-02 Thread Ltc Hotspot
addresses.add(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 5:45 PM, Emile van Sebille wrote: > On 8/1/2015 4:07 PM, Ltc Hotspot wrote: > >&

Re: [Tutor] String Attribute

2015-08-02 Thread Ltc Hotspot
addresses.add(line4) count = count + 1 print addresses print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 5:44 PM, Alan Gauld wrote: > On 02/08/15 00:07, Ltc Hotspot wrote: > >> Question1:

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
..@uct.ac.za david.horw...@uct.ac.za david.horw...@uct.ac.za stephen.marqu...@uct.ac.za lo...@media.berkeley.edu lo...@media.berkeley.edu r...@media.berkeley.edu c...@iupui.edu c...@iupui.edu c...@iupui.edu There were 27 lines in the file with From as the first word Regards, Hal On Sat, Aug 1, 2

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
addresses = set() for addr in [ fromline.split()[0] for fromline in mbox.split('From ') if fromline ]: count = count + 1 print addr print "There were", count, "lines in the file with From as the first word" Regards, Hal On Sat, Aug 1, 2015 at 2

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
tents of the file mbox-short.txt? (or the first > 5-10 address sets if this is only representative) I think if we have a > better understanding of the structure of the content you're parsing it'll > help us identify what the program will need to be prepared to handle. > > Emile

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
gt; > Emile > > > > On 7/31/2015 5:26 PM, Ltc Hotspot wrote: > >> Hi Mark, >> >> Desired output on execution of the script: >> >> stephen.marqu...@uct.ac.za >> lo...@media.berkeley.edu >> zq...@umich.edu >> rjl...@iupui.edu >> z

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
Hi Alan, There is an indent message in the revised code. Question: Where should I indent the code line for the loop? View the revised codes with loop indents, below: --->Revised Code v.2 wo/indent from lines 8-12: fname = raw_input("Enter file name: ") if len(fname) < 1 : fname = "mbox-short.t

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
Mark: Is this any better, message sent from GMail? Regards, Hal On Fri, Jul 31, 2015 at 5:02 PM, Mark Lawrence wrote: > On 31/07/2015 19:57, ltc.hots...@gmail.com wrote: > > I believe that this is the third time that you've been asked to do > something about the amount of whitespace that you're

Re: [Tutor] String Attribute

2015-08-01 Thread Ltc Hotspot
Hi Mark, Desired output on execution of the script: stephen.marqu...@uct.ac.za lo...@media.berkeley.edu zq...@umich.edu rjl...@iupui.edu zq...@umich.edu rjl...@iupui.edu [...] Regards, Hal On Fri, Jul 31, 2015 at 5:21 PM, Ltc Hotspot wrote: > Mark: > Is this any better, message sen