Discussion:
[Tutor] Dictionary Issue
Ltc Hotspot
2015-08-05 14:15:55 UTC
Permalink
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 read: ***@iupui.edu 5


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


Raw data code reads:



fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
text = handle.read()

## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.

addresses = set()
for addr in [ text.split()[2]('From ')
if fromline

## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.

count = dict()
for wrd in word:
count[wrd]= count.get(wrd,0) +1

## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.

maxval = none
maxkee = none
for kee, val in count.items():
if maxval == none or maxval <val:
maxval = val
maxkee = kee

print items


Question: What is the cause of the dictionary line message?


Regards,
Hal.
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-05 22:23:11 UTC
Permalink
Post by Ltc Hotspot
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.
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
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
text = handle.read()
## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.
addresses = set()
for addr in [ text.split()[2]('From ')
if fromline
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
maxval = val
maxkee = kee
print items
Question: What is the cause of the dictionary line message?
Learning to find these syntax errors is a skill you must learn for
yourself. Very often the error occurs one or even more lines before the
line on which the error is actually detected. So please go back from
where the error is actually reported and see what you can find. Very
strong hint, do not ask again until you've fixed at least two of the
three errors, and there may be more :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Clayton Kirkwood
2015-08-05 22:36:53 UTC
Permalink
-----Original Message-----
Behalf Of Mark Lawrence
Sent: Wednesday, August 05, 2015 3:23 PM
Subject: Re: [Tutor] Dictionary Issue
Post by Ltc Hotspot
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.
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
fname = raw_input("Enter file name: ") handle = open (fname, 'r') text
= handle.read()
## The program looks for 'From ' lines and takes the second ## word of
those lines as the person who sent the mail.
addresses = set()
for addr in [ text.split()[2]('From ')
if fromline
## The program creates a Python dictionary that maps ## the sender's
mail address to a count of the number ## of times they appear in the
file.
count = dict()
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads ## through the
dictionary using a maximum loop to ## find the greatest number of mail
messages.
maxval = none
maxkee = none
maxval = val
maxkee = kee
print items
Question: What is the cause of the dictionary line message?
Learning to find these syntax errors is a skill you must learn for
yourself. Very
often the error occurs one or even more lines before the line on which the
error is actually detected. So please go back from where the error is
actually
reported and see what you can find. Very strong hint, do not ask again
until
you've fixed at least two of the three errors, and there may be more :)
It looks like the problem is with count=dict()
Should be count=dict{}

I may be wrong - U'm still a neophyte.
crk

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-05 22:55:34 UTC
Permalink
Post by Clayton Kirkwood
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 uses ().

The more common way to create an empty dictionary
is to use {} alone, like:

count = {}

Although count is probably a bad name choice since
collections usually merit a plural name, eg counts

But the OP's problems lie earlier in the code,
as Mark has suggested.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-05 22:58:48 UTC
Permalink
Hi Mark,

Address identifies the email address with the maximum number of sends:
***@iupui.edu.

Secondly, we are missing a count on the number of messages sent by
***@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 key maxval and
retrieve a number count on the number of messages sent by ***@iupui.edu.


NameError:

Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in <module>()
22 ## find the greatest number of mail messages.
23
---> 24 maxval = none
25 maxkee = none
26 for kee, val in count.items():

NameError: name 'none' is not defined

In [52]: print address
***@iupui.edu

Revised data:


## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.

fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
for line in handle:
if line.startswith("From: "):
address = line.split()[1]


## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.

count = dict()
for wrd in address:
count[wrd]= count.get(wrd,0) +1

## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.

maxval = none
maxkee = none
for kee, val in count.items():
if maxval == none or maxval <val:
maxval = val
maxkee = kee


#items are printed

print address

Regards,
Hal
Post by Ltc Hotspot
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-06 01:21:25 UTC
Permalink
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
address = line.split()[1]
So far so good.
Post by Ltc Hotspot
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
But here you create a brand new dictionary.
Every time you go round the loop.
And it wipes out the old one.
You need to move that out of the loop.
address is a string. So wrd will be set to every
character in the string. I don;t think that's what
you want?
Post by Ltc Hotspot
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
See my previous email. none should be None.
Case matters in Python.
Post by Ltc Hotspot
maxval = val
maxkee = kee
#items are printed
print address
Notice that address gets reset every time the loop reads
a new line so this will only print the last address.
But maybe that's what you wanted?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 02:27:42 UTC
Permalink
Hi Alan


The output as reported by the latest code revision: ***@iupui.edu 1 ←
Mismatch

Looks like python continues to print the wrong data set:

In [11]: print val
1 In [12]: print kee ***@media.berkeley.edu In [13]: print address
***@iupui.edu
In order to complete the assignment, using data from the source file,
python must print the email address of the maximum sender and the number
of sends, i.e., ***@iupui.edu 5

I think the problem is in the placement of the counter?

Question: What is the source of the dictionary keys and values:
maxval = None
maxkee = None

Here is the latest revised code as follows:

fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
count = dict ()
for line in handle:
if line.startswith("From: "):
address = line.split()[1]
count[address]= count.get(address,0) +1

maxval = None
maxkee = None
for kee, val in count.items():

maxval = val
maxkee = kee

print address, val





Hal
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
Post by Ltc Hotspot
handle = open (fname, 'r')
address = line.split()[1]
So far so good.
Post by Ltc Hotspot
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
But here you create a brand new dictionary.
Every time you go round the loop.
And it wipes out the old one.
You need to move that out of the loop.
address is a string. So wrd will be set to every
character in the string. I don;t think that's what
you want?
count[wrd]= count.get(wrd,0) +1
Post by Ltc Hotspot
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
See my previous email. none should be None.
Case matters in Python.
Post by Ltc Hotspot
maxval = val
maxkee = kee
#items are printed
print address
Notice that address gets reset every time the loop reads
a new line so this will only print the last address.
But maybe that's what you wanted?
--> Did I resolve the reset in the revised code?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/li
Alan Gauld
2015-08-06 09:47:56 UTC
Permalink
Python will print what you ask it to. Don't blame the tool! :-)
Post by Ltc Hotspot
address = line.split()[1]
count[address]= count.get(address,0) +1
maxval = None
maxkee = None
maxval = val
maxkee = kee
print address, val
Look at the loops.

In the second loop you are no longer setting the values to
those of the max item but are setting them every time.
So at the end of the loop val holds the val of
the last item (and so does maxval so even if you used
that it would be the same result).

Similarly with the code for address. You are setting that
for each 'From ' line in your file so at the end of the loop
address is the last address in the file.

Now, dictionaries do not store data in the order that you
insert it, so there is no guarantee that the last item in
the dictionary loop is the same as the last address
you read.

You need to reinstate the test for max val in the second
loop and then print the kee that corresponds with that
(maxkee) as the address. ie. print maxkee and maxval.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailm
Ltc Hotspot
2015-08-06 18:30:29 UTC
Permalink
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 = open (fname, 'r')

counter = dict ()
c = Counter(['address'])

maxval = None
maxkee = None

for line in handle:
if line.startswith("From: "):
address = line.split()[1]

for maxkee, val in c.items():

maxval = val
maxkee = kee

print maxkee and maxval


Traceback message reads:
NameError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_16.py in <module>()
3
4 counter = dict ()
----> 5 c = Counter(['address'])
6
7 maxval = None

NameError: name 'Counter' is not defined


Regards,
Hal
Post by Alan Gauld
Python will print what you ask it to. Don't blame the tool! :-)
Post by Ltc Hotspot
address = line.split()[1]
count[address]= count.get(address,0) +1
maxval = None
maxkee = None
maxval = val
maxkee = kee
print address, val
Look at the loops.
In the second loop you are no longer setting the values to
those of the max item but are setting them every time.
So at the end of the loop val holds the val of
the last item (and so does maxval so even if you used
that it would be the same result).
Similarly with the code for address. You are setting that
for each 'From ' line in your file so at the end of the loop
address is the last address in the file.
Now, dictionaries do not store data in the order that you
insert it, so there is no guarantee that the last item in
the dictionary loop is the same as the last address
you read.
You need to reinstate the test for max val in the second
loop and then print the kee that corresponds with that
(maxkee) as the address. ie. print maxkee and maxval.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.pyt
Alan Gauld
2015-08-06 22:00:36 UTC
Permalink
Post by Ltc Hotspot
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.
Post by Ltc Hotspot
URL link to the revisions are available at http://tinyurl.com/nvzdw8k
Question: How do I define Counter
Counter is defined for you in the collections module.
So to use it you need to import collections and access it as
collections.Counter.

But did you read how to use it? It is a lot more than
just a dictionary, it has many extra methods, some of
which almost solve your problem for you. (Whether your
teacher will approve of using Counter is another
issue!)
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
counter = dict ()
c = Counter(['address'])
You only need to pass a list if you are adding multiple things.

But by the same token you can add a list of items, such
as email addresses. So if you had such a list you could
create a Counter() to hold them and count them for you.
And return the one with the highest value.
Sound familiar?

Please (re)read the Counter documentation.
Then play with one in the >>> prompt.
Don't expect us to just provide you with code, learn
how it works for yourself. Experiment.

The >>> prompt is your friend. You will learn more from that in 15
minutes than in a bunch of emails showing other peoples
code.

Alternatively forget about Counter and just go back to
your dict(). You have written all the code you need already,
you just need to assemble it in the correct order.
Post by Ltc Hotspot
maxval = None
maxkee = None
address = line.split()[1]
You are not storing the addresses anywhere.
Post by Ltc Hotspot
maxval = val
maxkee = kee
You are still not testing if its the maximum,
you just keep overwriting the variables for
each element.
Post by Ltc Hotspot
print maxkee and maxval
You still have an 'and' in there.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 23:11:02 UTC
Permalink
Post by Ltc Hotspot
I moved counter outside the loop and below dict, maxval = None
Post by Ltc Hotspot
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/nvzdw8k
Post by Ltc Hotspot
Question: How do I define Counter
Counter is defined for you in the collections module.
So to use it you need to import collections and access it as
collections.Counter.
But did you read how to use it? It is a lot more than
just a dictionary, it has many extra methods, some of
which almost solve your problem for you. (Whether your
teacher will approve of using Counter is another
issue!)
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
counter = dict ()
c = Counter(['address'])
You only need to pass a list if you are adding multiple things.
But by the same token you can add a list of items, such
as email addresses. So if you had such a list you could
create a Counter() to hold them and count them for you.
And return the one with the highest value.
Sound familiar?
Please (re)read the Counter documentation.
Then play with one in the >>> prompt.
Don't expect us to just provide you with code, learn
how it works for yourself. Experiment.
The >>> prompt is your friend. You will learn more from that in 15 minutes
than in a bunch of emails showing other peoples
code.
Alternatively forget about Counter and just go back to
your dict(). You have written all the code you need already,
you just need to assemble it in the correct order.
maxval = None
Post by Ltc Hotspot
maxkee = None
address = line.split()[1]
You are not storing the addresses anywhere.
Post by Ltc Hotspot
maxval = val
maxkee = kee
You are still not testing if its the maximum,
you just keep overwriting the variables for
each element.
print maxkee and maxval
You still have an 'and' in there.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
Hi Alan,

Questions(1):Why does print line, prints blank space; and, (2) print
address prints a single email address:

View print results as follows:

In [70]: %run assignment_9_4_24.py
Enter file name: mbox-short.txt
***@media.berkeley.edu 1

In [71]: print handle
<open file 'mbox-short.txt', mode 'r' at 0x00000000035576F0>

In [72]: print count
{'***@gmail.com': 1, '***@media.berkeley.edu': 3,
'***@iupui.
edu': 5, '***@caret.cam.ac.uk': 1, '***@iupui.edu': 2,
'***@umich.ed
u': 3, '***@uct.ac.za': 4, '***@iupui.edu': 1, '
***@umich.edu':
4, '***@uct.ac.za': 2, '***@media.berkeley.edu': 1}

In [73]: print line


In [74]: print address
***@iupui.edu


Question(3): why did the elements print count('keys') and print
count('items') fail?

View print commands as follows:


In [75]: dir (count)
Out[75]:
['__class__',
'__cmp__',
'__contains__',
'__delattr__',
'__delitem__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
'__gt__',
'__hash__',
'__init__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setitem__',
'__sizeof__',
'__str__',
'__subclasshook__',
'clear',
'copy',
'fromkeys',
'get',
'has_key',
'items',
'iteritems',
'iterkeys',
'itervalues',
'keys',
'pop',
'popitem',
'setdefault',
'update',
'values',
'viewitems',
'viewkeys',
'viewvalues']

In [76]:

---------------------------------------------------------------------------
TypeError
Traceback (most recent call last)
<ipython-input-76-35c8707b256e> in <module>()
----> 1 print count('items')

TypeError: 'dict' object is not callable

In [77]: print count('keys')
---------------------------------------------------------------------------
TypeError
Traceback (most recent call last)
<ipython-input-77-54ed4a05a3c7> in <module>()
----> 1 print count('keys')

TypeError: 'dict' object is not callable

In [78]:


Regards,
Hal
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-06 23:20:15 UTC
Permalink
Post by Ltc Hotspot
Questions(1):Why does print line, prints blank space; and, (2) print
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 empty.,
Post by Ltc Hotspot
In [72]: print count
Question(3): why did the elements print count('keys') and print
count('items') fail?
Because, as shown above, count is a dictionary.
So items and keys are methods not strings to be passed
to a non-existent count() function.

So you need, for example:

print count.keys()
Post by Ltc Hotspot
Traceback (most recent call last)
<ipython-input-76-35c8707b256e> in <module>()
----> 1 print count('items')
TypeError: 'dict' object is not callable
Which is what the error is also telling you.
You cannot call - ie use () - with a dictionary like count.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-07 00:15:56 UTC
Permalink
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 <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 count = dict.keys()
4 for line in handle:
5 if line.startswith("From: "):

TypeError: descriptor 'keys' of 'dict' object needs an argument

In [99]:

Question2: Are all the loop failures resolved in the revised code?

Revised code is available at
https://gist.github.com/ltc-hotspot/00fa77ca9b40c0a77170

Regards,
Hal
Post by Alan Gauld
Post by Ltc Hotspot
Questions(1):Why does print line, prints blank space; and, (2) print
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 empty.,
In [72]: print count
Post by Ltc Hotspot
Question(3): why did the elements print count('keys') and print
count('items') fail?
Because, as shown above, count is a dictionary.
So items and keys are methods not strings to be passed
to a non-existent count() function.
print count.keys()
Traceback (most recent call last)
Post by Ltc Hotspot
<ipython-input-76-35c8707b256e> in <module>()
----> 1 print count('items')
TypeError: 'dict' object is not callable
Which is what the error is also telling you.
You cannot call - ie use () - with a dictionary like count.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-07 06:35:05 UTC
Permalink
Post by Ltc Hotspot
Question1: How type of argument should I use for dict, i.e.,user argument
or list argument.
TypeError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 count = dict.keys()
You appear to be making random changes to your code
for no good reason.

I will not make any further suggestions until you
start to explain your thinking.

What do you think the line

count = dict.keys()

will do? Why do you want to do that?
How will it help you solve your problem?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-07 18:18:16 UTC
Permalink
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?

Question2: dict maps strings into keys and values?


Hal
Post by Alan Gauld
Post by Ltc Hotspot
Question1: How type of argument should I use for dict, i.e.,user argument
or list argument.
TypeError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 count = dict.keys()
You appear to be making random changes to your code
for no good reason.
I will not make any further suggestions until you
start to explain your thinking.
What do you think the line
count = dict.keys()
will do? Why do you want to do that?
How will it help you solve your problem?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
http://www.flickr.com/photos/alangauldphotos
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-07 21:20:10 UTC
Permalink
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 it hard to know whether you understand what is
going on and to guide you to a solution.
Post by Ltc Hotspot
right, view a copy of the revised code at
http://tinyurl.com/nvzdw8k
OK, You have only posted partial code because you don't have
the part where you read the filename etc. But assuming it
has not changed then the new code looks correct - almost.

Your assignment said NOT to use the lines starting From: (with
colon :) But your code tests for startswith('From: ') so you
are doing what you were told not to do.

If you remove the colon from the end of From (but keep the space)
it should be correct.
Post by Ltc Hotspot
Question1: are these assumptions true, above?
Yes, pretty much correct.
Post by Ltc Hotspot
Question2: dict maps strings into keys and values?
Not quite. A dictionary has a key and a corresponding value.
The key can be ANY immutable (unchangeable) object - string,
integer, tuple, etc.
The value can be any Python object.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-08 18:38:35 UTC
Permalink
Post by Ltc Hotspot
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 new Counter, overwriting the
previous one.
At the end of the loop you will have exactly 1 Counter containing the
last item
in the loop and a count of 1.

Instead create the Counter before the loop and then use the update()
method to add the address to it. Recall we talked about reading the Counter
documentation? It describes the update() method.

One you have the Counter with all the addresses in you can get the max
value
and key directly without using a second loop and your maxkee and maxval
variables.

Again read the Counter documentation to see how.

Finally remember the imports. You never show us those but the Counter will
not work unless you import it.
Post by Ltc Hotspot
Question: What is the cause of the empty dict?
You create it but never use it. You replaced the line where count got
populated with your Counter call. So count never gets populated.
Just because Counter sounds like count does not mean they are
in any way connected.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-06 04:03:29 UTC
Permalink
Post by Ltc Hotspot
Hi Mark,
Secondly, we are missing a count on the number of messages sent by
Thirdly, maxval 'none' is not defined on line # 24
Questions: How do we define the value of none for the key maxval and
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in <module>()
22 ## find the greatest number of mail messages.
23
---> 24 maxval = none
25 maxkee = none
NameError: name 'none' is not defined
In [52]: print address
## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
address = line.split()[1]
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
maxval = val
maxkee = kee
You can greatly simplify all of the above code if you use a Counter from
the collections module
https://docs.python.org/3/library/collections.html#collections.Counter
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 04:22:13 UTC
Permalink
Mark,

Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?

Regards,
Hal
Post by Mark Lawrence
Post by Ltc Hotspot
Hi Mark,
Secondly, we are missing a count on the number of messages sent by
Thirdly, maxval 'none' is not defined on line # 24
Questions: How do we define the value of none for the key maxval and
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in <module>()
22 ## find the greatest number of mail messages.
23
---> 24 maxval = none
25 maxkee = none
NameError: name 'none' is not defined
In [52]: print address
## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
address = line.split()[1]
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
maxval = val
maxkee = kee
You can greatly simplify all of the above code if you use a Counter from
the collections module
https://docs.python.org/3/library/collections.html#collections.Counter
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-06 15:28:44 UTC
Permalink
On 06/08/2015 05:22, Ltc Hotspot wrote:

Please don't top post here, it makes following long threads difficult.
Post by Ltc Hotspot
Mark,
Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?
Try it at the interactive prompt and see what happens.
Post by Ltc Hotspot
Regards,
Hal
Post by Mark Lawrence
Post by Ltc Hotspot
Hi Mark,
Secondly, we are missing a count on the number of messages sent by
Thirdly, maxval 'none' is not defined on line # 24
Questions: How do we define the value of none for the key maxval and
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_5.py in <module>()
22 ## find the greatest number of mail messages.
23
---> 24 maxval = none
25 maxkee = none
NameError: name 'none' is not defined
In [52]: print address
## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
address = line.split()[1]
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
maxval = val
maxkee = kee
You can greatly simplify all of the above code if you use a Counter from
the collections module
https://docs.python.org/3/library/collections.html#collections.Counter
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 17:17:39 UTC
Permalink
Post by Mark Lawrence
Please don't top post here, it makes following long threads difficult.
Mark,
Post by Ltc Hotspot
Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?
Try it at the interactive prompt and see what happens.
NameError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\new.txt in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 c = Counter(['address'])
4
5
NameError: name 'Counter' is not defined


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:
if line.startswith("From: "):
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval


In [20]:
Hal
Post by Mark Lawrence
Post by Ltc Hotspot
Post by Ltc Hotspot
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-06 18:30:07 UTC
Permalink
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
c = Counter(['address'])
count = dict ()
maxval = None
maxkee = None
maxval = val
maxkee = kee
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval
Let's hold up here a second. You do understand that
Python executes your code from top to bottom, yes?

So reading your code from the top you have a loop that
sets maxval and maxkee before you even put anything
into count. How do you think that would ever work?

You have a lot of people spending time trying to
help you here, but you do need to exercise a little
bit of insight yourself. That code can never work
and it has nothing to do with Pyhon it is your
logic that is faulty.

Try working through it with a pencil and paper.
Write down what each variable contains at each
stage of the program. (or just print it to see).

You have been very close to a solution but you
seem to be getting farther away rather than closer
which suggests you are trying stuff without
understanding why.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-06 18:59:37 UTC
Permalink
Post by Ltc Hotspot
Post by Mark Lawrence
Please don't top post here, it makes following long threads difficult.
Mark,
Post by Ltc Hotspot
Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?
Try it at the interactive prompt and see what happens.
NameError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\new.txt in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 c = Counter(['address'])
4
5
NameError: name 'Counter' is not defined
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
c = Counter(['address'])
count = dict ()
maxval = None
maxkee = None
maxval = val
maxkee = kee
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval
You obviously haven't bothered to read the link I gave you about the
Counter class so I give up.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 19:05:45 UTC
Permalink
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
Post by Mark Lawrence
Post by Ltc Hotspot
c = Counter(['eggs', 'ham'])
Please don't top post here, it makes following long threads difficult.
Mark,
Post by Ltc Hotspot
Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?
Try it at the interactive prompt and see what happens.
NameError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\new.txt in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 c = Counter(['address'])
4
5
NameError: name 'Counter' is not defined
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
c = Counter(['address'])
count = dict ()
maxval = None
maxkee = None
maxval = val
maxkee = kee
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval
You obviously haven't bothered to read the link I gave you about the
Counter class so I give up.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-06 23:53:29 UTC
Permalink
Post by Ltc Hotspot
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 rest of the methods on the class do?
Post by Ltc Hotspot
Post by Mark Lawrence
Post by Mark Lawrence
Please don't top post here, it makes following long threads difficult.
What did you not understand about the above?
Post by Ltc Hotspot
Post by Mark Lawrence
You obviously haven't bothered to read the link I gave you about the
Counter class so I give up.
If you'd read the entire write up why are you still wasting time with a
loop to find a maximum that simply doesn't work, when there is likely a
solution in the Counter class right in front of your eyes?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-07 00:30:43 UTC
Permalink
Mark,

I'm following the instructor's video exercise, available at


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
Post by Mark Lawrence
Post by Ltc Hotspot
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 rest of the methods on the class do?
Please don't top post here, it makes following long threads difficult.
What did you not understand about the above?
You obviously haven't bothered to read the link I gave you about the
Post by Ltc Hotspot
Post by Mark Lawrence
Counter class so I give up.
If you'd read the entire write up why are you still wasting time with a
loop to find a maximum that simply doesn't work, when there is likely a
solution in the Counter class right in front of your eyes?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-07 07:14:11 UTC
Permalink
Post by Ltc Hotspot
Mark,
I'm following the instructor's video exercise, available at
http://youtu.be/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?
top posted, again, *plonk*
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-07 18:53:02 UTC
Permalink
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
Post by Mark Lawrence
Post by Ltc Hotspot
Mark,
I'm following the instructor's video exercise, available at
http://youtu.be/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?
top posted, again, *plonk*
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Emile van Sebille
2015-08-07 13:29:48 UTC
Permalink
Post by Ltc Hotspot
I'm following the instructor's video exercise, available at
http://youtu.be/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 in a time tested way.

See https://docs.python.org/2/tutorial/ for python2 or
https://docs.python.org/3/tutorial/ for python3.

Emile



_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-06 19:24:29 UTC
Permalink
Post by Ltc Hotspot
Post by Ltc Hotspot
Post by Ltc Hotspot
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?
Post by Ltc Hotspot
Post by Ltc Hotspot
NameError
Traceback (most recent call last)
2 handle = open (fname, 'r')
----> 3 c = Counter(['address'])
NameError: name 'Counter' is not defined
So where do you define Counter? Do you import the module?
Do you import Counter from the module?
It's not shown in your code.
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
c = Counter(['address'])
count = dict ()
maxval = None
maxkee = None
maxval = val
maxkee = kee
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval
You have introduced an 'and' here which makes no sense.
It will try to print the logical AND of the two values.
That's not what you want.

Please try to work through this manually and see
how it works (or doesn't). There is no point in folks
making suggestions for improvements until you
understand how it should work yourself.b You have
all the components needed to build the solution,
now its up to you to fit them together such that
they work. We can make suggestions but you need
to solve the problem, we can't, and won't do it
for you.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ltc Hotspot
2015-08-06 18:32:58 UTC
Permalink
Mark,

Visit the following URL link to view a captured copy of the latest code
revision, available at http://tinyurl.com/nvzdw8k

Regards,
Hal
Post by Ltc Hotspot
Post by Mark Lawrence
Please don't top post here, it makes following long threads difficult.
Mark,
Post by Ltc Hotspot
Replace count[address]= count.get(address,0) +1 with c =
Counter(['address'])?
Try it at the interactive prompt and see what happens.
NameError
Traceback (most recent call last)
C:\Users\vm\Desktop\apps\docs\Python\new.txt in <module>()
1 fname = raw_input("Enter file name: ")
2 handle = open (fname, 'r')
----> 3 c = Counter(['address'])
4
5
NameError: name 'Counter' is not defined
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
c = Counter(['address'])
count = dict ()
maxval = None
maxkee = None
maxval = val
maxkee = kee
address = line.split()[1]
count[address]= count.get(address,0) +1
print maxkee and maxval
Hal
Post by Mark Lawrence
Post by Ltc Hotspot
Post by Ltc Hotspot
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Danny Yoo
2015-08-05 22:29:22 UTC
Permalink
Post by Ltc Hotspot
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 problem.

... Reading...

The for loop looks odd because there's a leading open bracket that looks
out of place.

for addr in [ text.split()[2]('From ')

The following line uses an if conditional, but needs to offset the block
with a ":" that appears to be missing.

if fromline
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-05 23:11:57 UTC
Permalink
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...
Post by Ltc Hotspot
fname = raw_input("Enter file name: ")
handle = open (fname, 'r')
text = handle.read()
## The program looks for 'From ' lines and takes the second
## word of those lines as the person who sent the mail.
addresses = set()
for addr in [ text.split()[2]('From ')
if fromline
The above looks like its supposed to be a list
comprehension embedded in a for loop. Putting too much
code in one line is usually a bad idea especially before
you have it working.

Try separating out the formation of your list from the
for loop. Once you get the comprehension working correctly
then you can consider embedding it.

As for the expression

text.split()[2]('From ')

Can you explain how you think that works?
Try it at the >>> prompt with text set to
a sample line of data.

Try
Post by Ltc Hotspot
text = ...... # whatever your data looks like
text.split()
text.split[2]
text.split()[2]('From ')
The >>> prompt is one of your most powerful tools while
writing code, you should always have one ready to try
stuff out. You can answer a lot of questions that way.
Post by Ltc Hotspot
## The program creates a Python dictionary that maps
## the sender's mail address to a count of the number
## of times they appear in the file.
count = dict()
What is word? You don't define it anywhere?
Post by Ltc Hotspot
count[wrd]= count.get(wrd,0) +1
## After the dictionary is produced, the program reads
## through the dictionary using a maximum loop to
## find the greatest number of mail messages.
maxval = none
maxkee = none
none is not a value in Python.
You need to spell it None
You don't really need the maxval == None check since None
is considered less that all other numbers.
Post by Ltc Hotspot
maxval = val
maxkee = kee
print items
What is items? It is not defined anywhere above.
count.items is not the same as items.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alan Gauld
2015-08-06 01:27:43 UTC
Permalink
In [3]: %run assignment_9_4_9.py
Enter file name: mbox-short.txt
See my other post.
Count the number of letters in the address.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Continue reading on narkive:
Loading...