Function Details: pop_(dict)

Description


Removes specified key and return the corresponding value.


Extended Description


The pop() method removes the item with the specified key from the dictionary and returns its value. If the key is not found and a default value is provided, it returns the default value. If the key is not found and no default value is provided, it raises a KeyError. This method modifies the dictionary in-place.


Function Signature


dict.pop(key: Any, default: Any = None) -> Any

Module: dict

Class: dictionary

Parameters



Parameter List


  • key: Any
  • default: Any

Return


Returns the value associated with the removed key. If the key is not found and a default is provided, returns the default value.


Return Type


Any

Output

Explanation

This example shows how to use pop() to remove and return a value from the dictionary.