Answer:
Attached below is the screen shot of the code
Explanation:
The screenshot of the Lines of code that Checks ; precondition , raises a KeyError when necessary and also represents the precondition, and postcondition is attached below from my VS code