Python

Python Menu

Python

Python Dictionary popitem() - Definition, Syntax, Parameters, Examples

Definition

The popitem() method removes the item that was last inserted into the dictionary. In versions before 3.7, the popitem() method removes a random item.

The removed item is the return value of the method, as a tuple.

Syntax

dictionary.popitem()

Parameters

No Parameters.

Examples:

person = { "name": "Raymond", "age": 29, "country": "Japan" } person.popitem() print(person)
# another example person = { "name": "Raymond", "age": 29, "country": "Japan" } j = person.popitem() print(j)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods