code: def expand_ipv6 (ip, num):
      
      i = ip.find("::")
      prefix = ip[:i]
      suffix = ip[i + 2:]
      count = prefix.count(":") + suffix.count(":")
      if prefix:
          count += 1
          prefix = prefix + ":"
      if suffix:
          count += 1
          suffix = ":" + suffix
      if count >= num:
          raise ValueError("invalid ipv6 number: %s" % ip)
      fill = (num - count - 1) * "0:" + "0"
      return prefix + fill + suffix
docs: Expand an IPv6 address with included :: to num octets.
  
      @raise: ValueError on invalid IP addresses