def add(key, id, value=None) if id in dictionary: if key in alias: # Do nothing pass else: alias[key] = id else: dictionary[id] = value alias[key] = id add('e', 'id2') add('f', 'id3', 3) While this works, I think ultimately
@user1162512 if you want to have more than one value for a certain key, then you'll need to use a list or some other container for multiple values (another dict, a tuple, etc.). You can't do {"abc": 1, 2} as a dict is a key:value pair, w
I have a case where the same key could have different strings associated with it. e.g. flow and wolf both have the same characters, if I sort them and use them as keys in a dictionary, I want to put the original strings as values. I tried in a python dict
Post a Comment:
Showing 0 Comments: