Python Dictionary popitem() method

The dictionary.popitem() method in Python removes the item that was last inserted into the dictionary.

Syntax

Parameter

NA

Return

This method returns an arbitrary element (key, value) pair from the given dictionary or raises a KeyError if the specified dictionary is null.

Example 1

Output

Example 2

Output

Pin It on Pinterest

Share This