Ask Question
Yesterday, 20:41

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

+5
Answers (1)
  1. Yesterday, 20:55
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers