def validipaddr(address):
 try:
  octets = address.split('.')
  assert (len(octets) == 4)
  for x in octets:
   assert (0 <= int(x) <= 255)
 except (AssertionError, ValueError):
  return False
 return True

def validipaddr ( address ) : try : octets = address . split ( '.' ) assert ( len ( octets ) == 4 ) for x in octets : assert ( 0 <= int ( x ) <= 255 ) except ( AssertionError , ValueError ) : return False return True
returns true if address is a valid ipv4 address .