if/else inside the for loop
import os def ip_check(): hosts = [f'192.168.180.{index}' for index in range(100, 107)] for x in hosts: host_response = os.system(f"ping -n 1 {x}") if host_response == 0: print('command 1') else: print('command 2') ip_check()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags