Extract the key’s value if the key is present in the list and dictionary

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
  1. Take a dictionary and a key having a common value between them.
  2. Use for loop to iterate over keys and values of the dictionary.
  3. 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
				
			

create nested Dictionary using List.

remove keys with values greater than n.

Leave a Comment