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 empty.,
In [72]: print count
{'gopal.ramasammyc...@gmail.com
<mailto:gopal.ramasammyc...@gmail.com>': 1, 'lo...@media.berkeley.edu
<mailto:lo...@media.berkeley.edu>': 3, 'cwen@iupui.
edu': 5, 'antra...@caret.cam.ac.uk <mailto:antra...@caret.cam.ac.uk>':
1, 'rjl...@iupui.edu <mailto:rjl...@iupui.edu>': 2, 'gsil...@umich.ed
u': 3, 'david.horw...@uct.ac.za <mailto:david.horw...@uct.ac.za>': 4,
'wagne...@iupui.edu <mailto:wagne...@iupui.edu>': 1, 'zq...@umich.edu
<mailto:zq...@umich.edu>':
4, 'stephen.marqu...@uct.ac.za <mailto:stephen.marqu...@uct.ac.za>':
2, 'r...@media.berkeley.edu <mailto:r...@media.berkeley.edu>': 1}
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()
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 - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor