code: def isHex(val: str) -> bool:
      
      if isinstance(val, bytes):
          # only decodes utf-8 string
          try:
              val = val.decode()
          except ValueError:
              return False
      return isinstance(val, str) and all(c in string.hexdigits for c in val)
docs: Return whether the given str represents a hex value or not
  
      :param val: the string to check
      :return: whether the given str represents a hex value