def is_valid_ipv6(ip):
 try:
  socket.inet_pton(socket.AF_INET6, ip)
 except socket.error:
  return False
 return True

def is_valid_ipv6 ( ip ) : try : socket . inet_pton ( socket . AF_INET6 , ip ) except socket . error : return False return True
validates ipv6 addresses .