- 1
Why it isn't working
import nmap class Network(object): def __init__(self): ip = input("please enter ip default is 198.168.1.1/192.1687.0.1") self.ip = ip def networkscanner(self): if len(self.ip) == 0: network = '192.168.1.1/24' else: network = self.ip + '/24' print("scanning please wait ---->") nm = nmap.PortScanner() nm.scan(hosts=network, arguments='-sn') hosts list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()] for host, status in hosts_list: print("host\t{}".format(host)) if __name__ == "__main__" D = Network() D.networkscanner() Link(https://code.sololearn.com/cGPVpcCaIyUV/?ref=app)
6 odpowiedzi
+ 3
azzziz the legend ,
can you please give a more precise description about the error message?
what have you done so far to identify the issue?
thanks!
+ 3
azzziz the legend ,
as Emerson Prado already mentioned, you should fix the indentation in your code. since your profile does not show that you have done and finished a python beginners tutorial in sololearn, it is recommended to do so.
without knowing the basics of python (like indentation,...) it will more be a trial and error instead of developing a code.
+ 2
Also, put your code in code playground and link it in the question. Don't make it too hard for those willing to help.
+ 1
azzziz the legend The indentation is quite messed up. For Python, indentation is critical - that's what it uses to identify blocks.
Fix indentation. You can use 4 spaces per level, which you get in Code Playground with tab button.
Then, if it still doesn't work, pls answer Lothar question.
+ 1
Lothar this is the playground https://code.sololearn.com/cGPVpcCaIyUV/?ref=app (it says that there is an invalid syntax in the 9th line