dict extract key by value code example
Example 1: how to get value from key dict in python
# Get a value from a dictionary in python from a key
# Create dictionary
dictionary = {1:"Bob", 2:"Alice", 3:"Jack"}
# Retrieve value from key 2
entry = dictionary[2]
# >>> entry
# Alice
Example 2: extract values from dict python
>>> d = {1:-0.3246, 2:-0.9185, 3:-3985}
>>> d.values()
<<< [-0.3246, -0.9185, -3985]