John Machin wrote: > freq_dict = {} > ... > if thing in freq_dict: > freq_dict[thing] += 1 > else: > freq_dict[thing] = 1 > > or, less plainly, > > freq_dict[thing] = freq_dict.get(thing, 0) + 1
or try: freq_dict[thing] += 1 except KeyError: freq_dict[thing] = 1 STeVe -- http://mail.python.org/mailman/listinfo/python-list