from collections import defaultdict
# Two lists: one with numeric keys, one with string values
list1 = [5, 3, 1, 9, 48, 21]
list2 = ['bbb', 'ccc', 'tt', 'p', 'qqqq', 'mmm']
# defaultdict(list) automatically creates an empty list for new keys
# defaultdict(list) is a special type of dictionary that
# automatically creates a default value for any missing key
result_dict = defaultdict(list)
# zip pairs elements: (5, 'bbb'), (3, 'ccc'), ...
for key, value in zip(list1, list2):
# Append each value to the list associated with its key
result_dict[key].append(value)
# Convert defaultdict back to a normal dictionary
result_dict = dict(result_dict)
print("dictionary:", result_dict)
'''
run:
dictionary: {5: ['bbb'], 3: ['ccc'], 1: ['tt'], 9: ['p'], 48: ['qqqq'], 21: ['mmm']}
'''