At Meta, systems such as network-facing services and internal traffic filters need strict IP parsing. Implement a function that takes a string and returns whether it is a valid IPv4 address, valid IPv6 address, or Neither.
Write a function validate_ip(address) that accepts a string address and returns one of:
"IPv4" if the string is a valid IPv4 address"IPv6" if the string is a valid IPv6 address"Neither" otherwiseA valid IPv4 address has exactly 4 decimal parts separated by .. Each part must contain only digits, be in the range 0 to 255, and must not contain leading zeros unless the part is exactly "0".
A valid IPv6 address has exactly 8 parts separated by :. Each part must be 1 to 4 characters long and contain only hexadecimal characters: 0-9, a-f, or A-F.
Example 1
address = "172.16.254.1""IPv4"0..255, and no invalid leading zeros.Example 2
address = "2001:0db8:85a3:0:0:8A2E:0370:7334""IPv6"1 <= len(address) <= 100., :, or other ASCII characters