Ask Question
8 June, 20:50

You created the following dictionary relationships = {'Jimmy':'brother', 'Carol':'sister'}. You then executed the following code, and received a KeyError exception. What is the reason for the exception? relationships['jimmy']

+2
Answers (1)
  1. 9 June, 00:03
    0
    This is because the key in relationships['jimmy'] is wrong. The first letter "j" should be uppercase. The key in the given dictionary is "Jimmy" and therefore a lowercase "j" will result in a KeyError exception. The key is case sensitive and therefore a minor mistake in a single letter either in lowercase or uppercase will cause the error. The correct usage of key to address the value should be relationships["Jimmy"].
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “You created the following dictionary relationships = {'Jimmy':'brother', 'Carol':'sister'}. You then executed the following code, and ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers