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