code: def check_ipv4(ip_str):
      
      try:
          socket.inet_pton(socket.AF_INET, ip_str)
      except AttributeError:
          try:
              socket.inet_aton(ip_str)
          except socket.error:
              return False
          return ip_str.count('.') == 3
      except socket.error:
          return False
      return True
docs: Return True if is a valid IP v4