Python program to remove a key from the dictionary.

In this python dictionary program, we will remove a key from the dictionary.

Steps to solve the program
  1. Take a dictionary as input.
  2. Using an if-else statement remove the given key from the dictionary.
  3. Print the output.
				
					dict1 =  {'a':2,'b':4,'c':5}
dict2={}

for key,val in dict1.items():
    if key != "c":
        dict2[key]=val
        
print(dict2)
				
			

Output :

				
					{'a': 2, 'b': 4}
				
			

find the product of all items in the dictionary.

map two lists into a dictionary.

Leave a Comment