An IP address is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. There are two versions of the Internet protocol, and thus two versions of addresses. One of them is the IPv4 address.
defisIPv4Address(inputString): dotidxlist = [] if len(inputString) >= 15or len(inputString) < 8: returnFalse else: for i in range(len(inputString)): if inputString[i] == ".": dotidxlist.append(i)
if len(dotidxlist) != 3: returnFalse else: for i in range(len(dotidxlist)): if i == 0: try: Temp = int(inputString[0:dotidxlist[i]]) if Temp < 0or Temp > 255: returnFalse except: returnFalse
elif i == len(dotidxlist)-1: try: Temp1 = int(inputString[dotidxlist[i-1]+1:dotidxlist[i]]) if Temp1 < 0or Temp1 > 255: returnFalse except: returnFalse