Python Att Dictionary Popitem
# Python2.x Python Dictionary popitem() Method
[ Python Dictionary](#)
* * *
## Description
The Python dictionary popitem() method returns and removes the last key-value pair from the dictionary.
If the dictionary is already empty and this method is called, a KeyError exception is raised.
## Syntax
The popitem() method syntax:
popitem()
## Parameters
* None
## Return Value
Returns a key-value pair in (key, value) form.
## Example
The following example demonstrates the use of the popitem() method:
## Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
site={'name': '','alexa': 10000,'url': 'www.'}
pop_obj=site.popitem()
print(pop_obj)
print(site)
The output result is:
('url', 'www.'){'alexa': 10000, 'name': 'xe8x8fx9cxe9xb8x9fxe6x95x99xe7xa8x8b'}
* * Python Dictionary](#)
YouTip