> I'd like to do the following, which doesn't work: > > a = {} > for key in keys: > a[key] += stringFunction() Use setdefault: a = {} for key in keys: a.setdefault(key, '') a[key] += stringFunction() // m -