English

Consider the following dictionary stateCapital: stateCapital = {"AndhraPradesh":"Hyderabad", "Bihar":"Patna","Maharashtra":"Mumbai", "Rajasthan":"Jaipur"} Find the output of the following statement:

Advertisements
Advertisements

Question

Consider the following dictionary stateCapital:

stateCapital = {"AndhraPradesh":"Hyderabad",
"Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}

Find the output of the following statement:

del stateCapital["Assam"]
print(stateCapital)
Very Short Answer
Advertisements

Solution

KeyError: 'Assam'

Because "Assam" is not present in the dictionary, the del statement gives an error, and print(stateCapital) is not executed.

shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Working with Lists and Dictionaries - Exercise [Page 76]

APPEARS IN

NCERT Informatics Practices [English] Class 11
Chapter 4 Working with Lists and Dictionaries
Exercise | Q 8. h) | Page 76
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×