0

I would like to create some sort of mapping so that given a string value, you get a number. However, there might be duplicate string values that belong to two different numbers, on which case they should both be stored in a collision list. My first take on this is to use a dictionary, however, python's standard dictionary don't create collision lists but only replaces the old number with the new number if the string key is the same. Do you have any dictionary library recommendations that might solve this problem?

Something like this:

dict['foo'] = 2
print(dict['foo'])
>>> 2
dict['foo'] = 5
print(dict['foo'])
>>> [2, 5]

Thanks

Alien13
  • 558
  • 3
  • 8
  • 30

0 Answers0