def is_ipv4(ip):
 try:
  return (ipaddress.ip_address(ip).version == 4)
 except ValueError:
  return False

def is_ipv4 ( ip ) : try : return ( ipaddress . ip_address ( ip ) . version == 4 ) except ValueError : return False
returns a bool telling if the value passed to it was a valid ipv4 address .