On Wed, 23 Jan 2013 10:12:25 +0000, Oscar Benjamin wrote:

> You can't retrieve the value of printque[val] if you haven't yet added
> an entry with the key val to the dict. Try this:
> 
> if val not in printque:
>     printque[val] = 1
> else:
>     printque[val] = printque[val] + 1

Another way of writing that is:

printque[val] = printque.get(val, 0) + 1



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to