def detect(target): list1=[] scn = nmap.PortScanner() scn.scan(hosts=target,arguments='-sP') if not scn.all_hosts(): print("Down") for host in scn.all_hosts(): print 'Live: ', host return(list1)