0

Here is the code I wrote:

import nmap

def menu():
    print (30 * "-", "I hate the CIA", 30 * "-")
    print ("1. Ping")
    print ("2. ???")
    print ("3. ???")
menu()
choice = input("Enter your choice [1 - 3]: ")
if choice==1:
    input("Please choose your target: ")
    t = nmap.PortScanner()
    t.scan(hosts=input, arguments='-sP')

I know it's probably very messy and it's likely bad practice to write in "to-be functionalities" like I have done, but I'm pretty new to this and I'm willing to take it out if there is a better way. Perhaps the answer is clear to me, maybe not. Help is appreciated. Thanks all <3

  • Where do you store the output of line `input("Please choose your target: ")`? Why is the part `hosts=input` referencing `input` function? – sanitizedUser May 24 '22 at 22:28

1 Answers1

0

input() always return a string.

Try:

...
if choice == '1':
   input("Please choose your target: ")
   ...

Alternatively if you want numerical values for 'choice', you can convert input string to integer:

choice = int(input("Enter your choice [1 - 3]: "))

But this will fail if user types non-numerical value.

LuckyDams
  • 109
  • 5