Skip to content

Instantly share code, notes, and snippets.

@oowasn
Created November 23, 2021 22:40
Show Gist options
  • Save oowasn/891e8c3612434228692e3e5f9cf914c3 to your computer and use it in GitHub Desktop.
Save oowasn/891e8c3612434228692e3e5f9cf914c3 to your computer and use it in GitHub Desktop.
# author -> geeksceo
def ipv6_verificator(str):
if (':' not in str) or (':'*3 in str) or (len(str.split(':')) < 8 and str.count('::') != 1) :
return "That's not IPv6 address !"
for i in str.split(':'):
if i != '':
try:
int(i, 16)
except ValueError:
return "This string is not in hexadecimal format, \n That's not IPv6 address !"
break
return "It's IPv6 Address !"
@oowasn
Copy link
Author

oowasn commented Nov 24, 2021

Verified if an address is an IPv6 address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment