Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

Python Dictionary popitem

by suresh

Python popitem Dictionary is one of a Dictionary function, used to remove last inserted key value pair, and prints the removed pair. In this article, we will show you, How to use this Python Dictionary popitem function with practical examples.

TIP: Please refer Dictionary article to understand everything about Dictionaries.

Python Dictionary popitem Syntax

The basic syntax behind this popitem function is:

dictionary_name.popitem()

Python Dictionary popitem Example

The python popitem dictionary function removes the last inserted key value pair and prints the removed items.

# Python Dictionary popitem Example

myDict = {1: 'apple', 2: 'Banana' , 3: 'Orange', 4: 'Kiwi'}
print("Dictionary Items: ", myDict)

# Pop Items
print("\nRemoved Item      :  ",  myDict.popitem())
print("Dictionary Items  :  ",  myDict)

# Add New Item
myDict[5] = 'Mango'
print("\nDictionary Items: ", myDict)

# Pop Items
print("\nRemoved Item      :  ",  myDict.popitem())
print("Dictionary Items  :  ",  myDict)

OUTPUT

Python Dictionary popitem Example

Placed Under: Python

Trending Posts

Python Program to Add two Lists

C Program to Sort Array in Descending Order

Tableau Rank Calculation Basic

MySQL Aggregate Functions

Useful System Stored Procedures in SQL

Python LOG

Row Count Transformation in SSIS

Create a Card in Power BI

Python ATAN2

Java toUpperCase Method

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy