In this python dictionary program, we will extract the key’s value if the key is present in the list and dictionary.
Steps to solve the program
- Take a dictionary and a key having a common value between them.
- Use for loop to iterate over keys and values of the dictionary.
- If the key is present in the dictionary, then print the value of that key.
A = ['sqatools','is','best']
B = {'sqatools':10}
for k,v in B.items():
if k in A:
print(v)
Output :
10