On Thursday, December 20, 2012 12:21:57 AM UTC+13, Thomas Bach wrote: > Hi, > > > > just as a side-note > > > > On Wed, Dec 19, 2012 at 02:45:13AM -0800, : > > > for word in list: > > > if word in dict: > > > count = dict[word] > > > count += 1 > > > dict[word] = count > > > else: > > > dict[word] = 1 > > > > When you got the indentation and names right, you can restate this as > > > > import collections > > counter = collections.Counter(words) > > > > in Python 2.7 or as > > > > import collections > > counter = collections.defaultdict(int) > > for word in words: > > counter[word] += 1 > > > > in Python 2.6 > > > > Regards, > > Thomas.
Thanks Thomas for your time... using 2.7 great! -- http://mail.python.org/mailman/listinfo/python-list