Ask Question
19 May, 17:47

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']

+1
Answers (1)
  1. 19 May, 21:34
    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?
Get an answer to your question ✅ “You created the following dictionary relationships = {'Jimmy':'brother', 'Carol':'sister'}. You then executed the following code, and ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers