In Python Dictionary popitem() method is used to remove and return the last element (key, value) pair inserted into the given dictionary.
Syntax:
No Parameters used in popitem() method.
Example:
#dictionary method STUDENT = {'Name': 'Phillip', 'Class': '10', 'Subject': 'Science'} result = STUDENT.popitem() print('Return Value = ', result) print('STUDENT = ', STUDENT) STUDENT['GRADE'] = 'A' result = STUDENT.popitem() print('Return Value = ', result) print('STUDENT=', STUDENT)