Computer Science

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)

Python Dictionaries

12 Likes

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)

Answered By

6 Likes


Related Questions