I am using python2.7 and trying to scan my network and print the host names of PCs on my n/w , i looked up on official docs of nmap , i tried but its not working i don't know why . Kindly guide me through the process or tell me where i am going wrong . Thanks in advance :)
hosts_list = [(x, nm[x]['status']['state'],nm[x].hostname()) for x in nm.all_hosts()]
for host, status,name in hosts_list:
print('{0}:{1}:{2}'.format(host, status,name))