# pip3 install ping3 from ping3 import ping ping_ok = lambda ip: False if ping(dest_addr=ip) is None else True print(ping_ok('192.168.11.1'))