- 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)

18th Apr 2022, 2:12 PM
Varin
Varin - avatar
6 Antworten
+ 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!
18th Apr 2022, 4:48 PM
Lothar
Lothar - avatar
+ 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.
21st Apr 2022, 9:54 AM
Lothar
Lothar - avatar
+ 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.
19th Apr 2022, 1:51 AM
Emerson Prado
Emerson Prado - avatar
+ 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.
21st Apr 2022, 12:24 AM
Emerson Prado
Emerson Prado - avatar
+ 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
21st Apr 2022, 12:28 AM
Varin
Varin - avatar