Quantcast
Channel: How to access key by value in a dictionary? - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by bg2094 for How to access key by value in a dictionary?

What you can do is make two lists. One which contains the keys and one which contains the values. Then for the index of the required value in the list with values you can call the key from the list of...

View Article



Answer by Hirabayashi Taro for How to access key by value in a dictionary?

If I understand correctly you should loop he dictionary instead of the tag list. You can check if the dictionary tags are in the list using sets.d = {"employee": ['PER', 'ORG'],"located": ["ORG",...

View Article

Answer by dteod for How to access key by value in a dictionary?

What you can do is to switch keys and values in the dict and then access by key.tags = ('PER', 'ORG')data = dict((val, key) for key, val in d.items())print(data[tags])Just be careful to convert the...

View Article

Answer by U13-Forward for How to access key by value in a dictionary?

You mean with... nothing?for x in q: if str(x) in d.values(): print(d.keys())

View Article

How to access key by value in a dictionary?

I have a dict that looks like the following:d = {"employee": ['PER', 'ORG']}I have a list of tags ('PER', 'ORG',....) that is extracted from the specific entity list.for t in entities_with_tag: # it...

View Article

Browsing latest articles
Browse All 5 View Live


Latest Images