Hello,

 : Sorry, it seems like I was not clear enough in that statement. I 
 : should have written something like "counting how many times each 
 : word occured" insted of "counting words".

You might like to try out collections.defaultdict().

  import collections

  summary = collections.defaultdict(int)
  for line in lines:
      words = line.strip().split()
      for word in words:
          summary[word] += 1

Lots of interesting features in the collections module...

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to