How to get multiple keys for values from a dictionary in Python


Post a Comment:





Showing 0 Comments:
Be the first to comment!

External ressources related to How to get multiple keys for values from a dictionary in Python

python - How do I make a dictionary with multiple keys to one ...
https://stackoverflow.com/questions/10123853/how-do-i-make-a-dictionary-with-multiple-keys-to-one-value

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

How to add multiple values to a dictionary key in python ...
https://stackoverflow.com/questions/20585920/how-to-add-multiple-values-to-a-dictionary-key-in-python

@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

How to have multiple values for a key in a python dictionary ...
https://stackoverflow.com/questions/48845260/how-to-have-multiple-values-for-a-key-in-a-python-dictionary

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