code: def randhex(ndigits: int) -> str:
      
      if not isinstance(ndigits, int):
          raise TypeError('number of digits must be an integer')
      if ndigits <= 0:
          raise ValueError('number of digits must be greater than zero')
  
      nbytes = ceil(ndigits / 2)
      rbytes = random_randbytes(nbytes)
      hexstr = rbytes.hex()[:ndigits]
  
      return hexstr
docs: Return a random text string of hexadecimal characters.
  
      The string has *ndigits* random digits.
      Raises ValueError if ndigits <= 0, and TypeError if it's not an integer.
  
      >>> randhex(16)  #doctest:+SKIP
      '56054d728fc56f63'