CBSE Class 11 Computer Science Question 100 of 112

Dictionaries — Question 22

Back to all questions
22
Question

Question 16

Fill in the blanks of the following code so that the values and keys of dictionary d are inverted to create dictionary fd.

d = {'a':1, 'b':2, 'c':3}
print(d)
fd = {}
for key, value in d.____():
  fd[____] = ____ 	
print(fd)
Answer
  1. items
  2. value
  3. key

The completed program is given below for reference:

d = {'a':1, 'b':2, 'c':3}
print(d)
fd = {}
for key, value in d.items():
  fd[value] = key 	
print(fd)