CBSE Class 11 Computer Science Question 33 of 88

Tuples and Dictionary — Question 13

Back to all questions
13
Question

Question 13

Which of the following will delete key-value pair for key = "Red" from a dictionary D1 ?

  1. delete D1("Red")
  2. del.D1("Red")
  3. del D1["Red"]
  4. del D1
Answer

del D1["Red"]

Reason — The syntax to delete a key-value pair from a dictionary in Python is : del dictionary_name[key]. Therefore, according to this syntax, del D1["Red"] is correct statement.