I have a large set of strings which I already know it holds an IP address and I want to determine if it's IPv4 or IPv6. Currently I'm checking whether the string contains a colon:
version = 4
if ':' in ip_string:
version = 6
Is there a faster way to determine the IP version, given that we already know it's an IP address. Is there any possibility that the above simple check can return the wrong result (for example is it possible to have an IPv6 address without a colon)?