Question: python def invertdict(A): invA = {} for key in A.keys(): invA[A[key]] = key return invA (i) What runtime errors can occur in invert dict? You
python
def invertdict(A):
invA = {}
for key in A.keys(): invA[A[key]] = key
return invA
(i) What runtime errors can occur in invert dict? You dont have to write the exact name of each error type, but you must explain where and how it may occur. Assume that the argument is a dictionary (that is, TypeError because the argument is not a dictionary is not an acceptable answer).
(ii) If A is a dictionary, is it always the case that invert dict(invert dict(A)) == A? (assuming no runtime error occurs). If yes, explain why. If no, give an example of an input dictionary that proves it.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
