Re: [Tutor] Dictionary Issue

2015-08-08 Thread Alan Gauld
On 08/08/15 00:05, Ltc Hotspot wrote: Hi Alan, On line 15, I replaced: 'count[address] = count.get(address, 0) + 1' with 'line = Counter(address)'. line = Counter(address) will create a new Counter object with the address in it with a count value of 1. Every line in the file will create a n

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Alan Gauld
On 07/08/15 19:18, Ltc Hotspot wrote: I want to find the max val , keys and values are defined on line 10: for kee, val in count.items(): Yes we know that, but you are not answering the questions we pose. Instead you seem to post random changes to your code and ask new questions which makes

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Ltc Hotspot
Hi Mark, Why is Counter not defined on line #15: line = Counter(address),i.e., NameError: name 'Counter' is not defined? Share a chat session at http://tinyurl.com/oull2fw View line entry at http://tinyurl.com/oggzn97 Hal On Fri, Aug 7, 2015 at 12:14 AM, Mark Lawrence wrote: > On 07/08/2015 0

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Ltc Hotspot
Alan, I want to find the max val , keys and values are defined on line 10: for kee, val in count.items(): Then, maxval determines the max value on line 11: if val > maxval: right, view a copy of the revised code at http://tinyurl.com/nvzdw8k Question1: are these assumptions true, above? Ques

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Emile van Sebille
On 8/6/2015 5:30 PM, Ltc Hotspot wrote: I'm following the instructor's video exercise, available at https://www.youtube.com/watch?v=3cwXN5_3K6Q. As you're clearly interested in learning python, you may find working the tutorial beneficial as it steps you through the fundamentals of python i

Re: [Tutor] Dictionary Issue

2015-08-07 Thread Mark Lawrence
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 counter: cou[wrd] =cou.get(wrd,0) +1 Please, explain the differences in counter

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
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 captured traceback: TypeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () 1 fname = raw_input("Ente

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
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 counter: cou[wrd] =cou.get(wrd,0) +1 Please, explain the differences in counter methods? Hal On Thu, Aug 6, 2015 at 4

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Question1: How type of argument should I use for dict, i.e.,user argument or list argument. Read captured traceback: TypeError Traceback (most recent call last) C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in () 1 fname = raw_input("Enter file name: ") 2 handle = open (fn

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
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 : That's nice to know. What do the

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 07/08/15 00:11, Ltc Hotspot wrote: Questions(1):Why does print line, prints blank space; and, (2) print address prints a single email address: See my previous emails. You are not storing your addresses so address only holds the last address in the file. line is at the end of the file so is

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 you > don't use it anywhere. >

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
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 you don't use it anywhere. URL link to the revisions are available at http://tinyurl.com/nvz

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
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 : >>> >>> c = Counter(['eggs', 'ham']) On Thu, Aug 6, 2015 at 11:59 AM, Mark

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/2015 05:22, Ltc Hotspot w

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Hi Alan, I moved counter outside the loop and below dict, maxval = None maxkee = None are both positioned outside the loop. URL link to the revisions are available at http://tinyurl.com/nvzdw8k Question: How do I define Counter Revised code reads: fname = raw_input("Enter file name: ") handle =

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 18:17, Ltc Hotspot wrote: Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])? You didn't do what Mark suggested. Did you read the documentation about Counter? NameError Traceback (most recent call last) 2 handle = open (fname, 'r') > 3 c =

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
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 here, it makes following long threads difficult. Mark, Replace count[address]= count.get(address,0) +1 with c = Counter(['address'])?

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 18:17, Ltc Hotspot wrote: View revised code here: fname = raw_input("Enter file name: ") handle = open (fname, 'r') c = Counter(['address']) count = dict () maxval = None maxkee = None for kee, val in count.items(): maxval = val maxkee = kee for line in handle:

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 = >> Counter(['address'])? >> > > Try it at the intera

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Mark Lawrence
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 = Counter(['address'])? Try it at the interactive prompt and see what happens. Regards, Hal On Wed, Aug 5, 2015 at

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Alan Gauld
On 06/08/15 03:27, Ltc Hotspot wrote: The output as reported by the latest code revision: c...@iupui.edu 1← Mismatch Looks like python continues to print the wrong data set: Python will print what you ask it to. Don't blame the tool! :-) > for line in handle: >

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 the maximum number of sends: >> c...

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
Hi Alan The output as reported by the latest code revision: c...@iupui.edu 1 ← Mismatch Looks like python continues to print the wrong data set: In [11]: print val 1 In [12]: print kee r...@media.berkeley.edu In [13]: print address c...@iupui.edu In order to complete the assignment, using data

Re: [Tutor] Dictionary Issue

2015-08-06 Thread Ltc Hotspot
The revised output reads: In [3]: %run assignment_9_4_9.py Enter file name: mbox-short.txt c...@iupui.edu 14 The desired output: c...@iupui.edu 5 Question: How do I trace the source of the count? Revised data code reads: fname = raw_input("Enter file name: ") handle = open (fname, 'r') count

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Mark Lawrence
On 05/08/2015 23:58, Ltc Hotspot wrote: 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: Ho

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Alan Gauld
On 06/08/15 02:05, Ltc Hotspot wrote: The revised output reads: In [3]: %run assignment_9_4_9.py Enter file name: mbox-short.txt c...@iupui.edu 14 The desired output: c...@iupui.edu 5 See my other post. Count the number of letters in the addres

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Alan Gauld
On 05/08/15 23:58, Ltc Hotspot wrote: fname = raw_input("Enter file name: ") handle = open (fname, 'r') for line in handle: if line.startswith("From: "): address = line.split()[1] So far so good. ## The program creates a Python dictionary that maps ## the sender's mail addres

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

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Alan Gauld
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 is definitely code not data. Meanwhile there are lots of issues in this code... fname = raw_input("Enter file name: ")

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Alan Gauld
On 05/08/15 23:36, Clayton Kirkwood wrote: It looks like the problem is with count=dict() Should be count=dict{} I may be wrong - U'm still a neophyte. Yes, you're wrong! :-) the correct form is as shown count = dict() Its calling the type operation which looks like any other function and

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Clayton Kirkwood
> -Original Message- > From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On > Behalf Of Mark Lawrence > Sent: Wednesday, August 05, 2015 3:23 PM > To: tutor@python.org > Subject: Re: [Tutor] Dictionary Issue > > On 05/08/2015 15:15, Ltc Hotspo

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Danny Yoo
> However, there is a traceback message: > > In [40]: %run 9_4_4.py > File "C:\Users\vm\Desktop\apps\docs\Python\_9_4_4.py", line 19 > count = dict() > ^ > SyntaxError: invalid syntax Syntax error reporting is approximate: you might need to look a few lines earlier to get at the root

Re: [Tutor] Dictionary Issue

2015-08-05 Thread Mark Lawrence
On 05/08/2015 15:15, Ltc Hotspot wrote: 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 num

[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