🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित में से कौन dictionary में कुंजी "tiger" के लिए कुंजी-मूल्य जोड़ी को हटा देगा?

Which of the following will delete the key-value pair for the key "tiger" in the dictionary?

dic = {"lion":"wild", "tiger":"wild", "cat":"domestic", "dog":"domestic"} 
A)
B)
C)
D)

Explanation:

The correct answer is (A) del dic["tiger"].

Explanation:

  • del dic["tiger"] is the correct way to delete the key-value pair for "tiger" from the dictionary.
  • It removes the key "tiger" and its associated value from the dictionary dic.

Other options are incorrect:

  • (B) dic["tiger"].delete(): There's no delete() method for dictionary values.
  • (C) delete(dic["tiger"]): There's no delete() function in Python for dictionaries.
  • (D) del(dic["tiger"]): This works but is less common. The more common form is del dic["tiger"].

So, (A) is the correct choice!

Latest Updates