Dec-08-2020, 11:50 PM
If it's just this one case, just replace it.
test['key1'] = [test['key1'], 2]The problem is if you need to do this and might want to keep extending the list. Best in that case is to never insert the int in the first place. Always have a list as the value (perhaps via defaultdict). Then you can just append whenever necessary.
import defaultdict test = defaultdict(list) #first element test['key1'].append(1) # second element test['key1'].append(2)