Single Choice Not Set

QWhat will be the output after the following statements?
x = {'day':'Sunday', 'week':10}
print(x['year'])

ID: #4022 Python Errors and Exceptions Handling 299 views
Question Info
#4022Q ID
Not SetDifficulty
Python Errors and Exceptions HandlingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A day
  • B KeyError
  • C Sunday
  • D 10
Correct Answer

Explanation

KeyError
 
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [103], in ()
      1 x = {'day':'Sunday', 'week':10}
----> 2 print(x['year'])

KeyError: 'year'

Share This Question

Challenge a friend or share with your study group.