get value of particular key in dictionary python code example

Example 1: python dictionary get default

dictionary = {"message": "Hello, World!"}

data = dictionary.get("message", "")

print(data)  # Hello, World!

Example 2: how to get key of a particular value in dictionary python using index

mydict = {'george': 16, 'amber': 19}
print(list(mydict.keys())[list(mydict.values()).index(16)])  # Prints george

Example 3: how to get the value of key in python

print(dict.get("key"))