code: def split_host(host):
      
      # host is IPv6?
      if '[' in host:
          return '', host, ''
      # host is IPv4?
      for c in host:
          if c not in IP_CHARS:
              break
      else:
          return '', host, ''
      # host is a domain name
      domain = subdomain = tld = ''
      parts = host.split('.')
      for i in range(len(parts)):
          tld = '.'.join(parts[i:])
          wildcard_tld = '*.' + tld
          exception_tld = '!' + tld
          if exception_tld in PSL:
              domain = '.'.join(parts[:i+1])
              tld = '.'.join(parts[i+1:])
              break
          if tld in PSL:
              domain = '.'.join(parts[:i])
              break
          if wildcard_tld in PSL:
              domain = '.'.join(parts[:i-1])
              tld = '.'.join(parts[i-1:])
              break
      if '.' in domain:
          subdomain, domain = domain.rsplit('.', 1)
      return subdomain, domain, tld
docs: Use the Public Suffix List to split host into subdomain, domain and tld.
  
      >>> split_host('foo.bar.co.uk')
      ('foo', 'bar', 'co.uk')