We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTimportreipv4=r'^(([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$'ipv6=r'^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$'for_inrange(int(input())):string=input()ifre.findall(ipv4,string):print('IPv4')elifre.findall(ipv6,string):print('IPv6')else:print('Neither')
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
IP Address Validation
You are viewing a single comment's thread. Return to all comments →
Easy Python3 solution: