Function Details: pop_(set)

Description


Removes and return an arbitrary set element. Raises KeyError if the set is empty.


Extended Description


The pop() method removes and returns an arbitrary element from the set. Since sets are unordered, there's no 'last' element, so the specific element removed is arbitrary. If the set is empty, pop() raises a KeyError. This method modifies the set in-place, reducing its size by one.


Function Signature


set.pop() -> Any

Module: set

Class: set

Parameters



Return


Returns an arbitrary element that was removed from the set.


Return Type


Any

Output

Explanation

This example shows how to use pop() to remove and return an arbitrary element from the set.