add list in dict if key exist value python code example Example: append to list in dictionary python if exists dic.setdefault(key,[]).append(value)