python ping ip address

import os

ip_list = ['']
for ip in ip_list:
    response = os.popen(f"ping {ip}").read()
    if "Received = 4" in response:
        print(f"UP {ip} Ping Successful")
        print(f"DOWN {ip} Ping Unsuccessful")

Here is what the above code is Doing:
1. We have a list of IP addresses.
2. We loop through the list of IP addresses.
3. For each IP address, we run a ping command.
4. We read the response from the ping command.
5. If the response contains the string “Received = 4”, we print “UP Ping Successful”.
6. If the response does not contain the string “Received = 4”, we print “DOWN Ping Unsuccessful”.