code: def assert_single_element(iterable):
    
    it = iter(iterable)
    first_item = next(it)
  
    try:
      next(it)
    except StopIteration:
      return first_item
  
    raise ValueError("iterable {!r} has more than one element.".format(iterable))
docs: Get the single element of `iterable`, or raise an error.
  
    :raise: :class:`StopIteration` if there is no element.
    :raise: :class:`ValueError` if there is more than one element.