On 06/08/2015 18:17, Ltc Hotspot wrote:
On Thu, Aug 6, 2015 at 8:28 AM, Mark Lawrence <breamore...@yahoo.co.uk>
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 interactive prompt and see what happens.
How do I define counter,view trace back:
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
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 - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor