LearnFrenzy
Sign in Take a free test

Dictionaries · Dictionaries MCQ · Question 6

What does popitem() remove? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

Which pair does d.popitem() remove?

  • A A random pair
  • B The first inserted pair
  • C The pair with the smallest key
  • D The most recently inserted pair Correct
Correct Answer: Option D

Since Python 3.7 popitem() works in LIFO order. It raises KeyError on an empty dict.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links