I am using Python 3.2.3 and want to change the default returned string value:
from collections import defaultdict
d=defaultdict(str)
d["NonExistent"]
The value returned is ''
. How can I change this so that when a key is not found, "unknown"
is returned instead of the empty string?