Assume that d has been initialized as an empty dictionary:
d = {}
Which of the following generates an error?
d[[1,2]] = 5
d[(1,2)] = 5
d["1,2"] = 5
d[12] = 5
Answer is d[[1,2]] = 5
Because dictionary uses values of unchangeable types as keys. Strings, ints and tuples are unchangeable, lists are not.
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
Python