हिंदी

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

Advertisements
Advertisements

प्रश्न

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)
अति संक्षिप्त उत्तर
Advertisements

उत्तर

KeyError: 'Assam'

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

shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 4: Working with Lists and Dictionaries - Exercise [पृष्ठ ७६]

APPEARS IN

एनसीईआरटी Informatics Practices [English] Class 11
अध्याय 4 Working with Lists and Dictionaries
Exercise | Q 8. h) | पृष्ठ ७६
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×