{"id":24057,"date":"2021-10-14T09:13:04","date_gmt":"2021-10-14T03:43:04","guid":{"rendered":"https:\/\/python-programs.com\/?p=24057"},"modified":"2021-11-05T17:14:08","modified_gmt":"2021-11-05T11:44:08","slug":"python-program-for-dictionary-popitem-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-dictionary-popitem-method\/","title":{"rendered":"Python Program for Dictionary popitem() Method"},"content":{"rendered":"

In the previous article, we have discussed Python Program for Dictionary keys() Function<\/a>
\nDictionary in python :<\/strong><\/p>\n

A dictionary is a set of elements that have key-value pairs. The values in the elements are accessed using the element\u2019s keys.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given dictionary = {'hello': 120, 'this': 130, 'is': 140, 'btechgeeks': 150}<\/pre>\n

Output:<\/strong><\/p>\n

The above given dictionary is :\r\n{'hello': 120, 'this': 130, 'is': 140, 'btechgeeks': 150}\r\nThe key-value pair removed from the given dictionary= ('btechgeeks', 150)\r\nThe above given dictionary after the removal of the last item(key-value):\r\n{'hello': 120, 'this': 130, 'is': 140}<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given dictionary = {10: 'good', 60: 'morning', 140: 'btechgeeks'}<\/pre>\n

Output:<\/strong><\/p>\n

The above given dictionary is :\r\n{10: 'good', 60: 'morning', 140: 'btechgeeks'}\r\nThe key-value pair removed from the given dictionary= (140, 'btechgeeks')\r\nThe above given dictionary after the removal of the last item(key-value):\r\n{10: 'good', 60: 'morning'}<\/pre>\n

Program for Dictionary popitem() Method in python<\/h2>\n