From 9c6675329f770d002c23baf578385fc1eed6e9bf Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Tue, 24 Jan 2023 05:55:43 -0800 Subject: [PATCH] Update nmap.py I have changed the if-else statement in the menuSelector() function to a switch statement, using a python dictionary. The switch statement checks if the menuChoice variable exists as a key in the dictionary and returns the corresponding value, --- nmap.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nmap.py b/nmap.py index 48b3895..b5f18da 100644 --- a/nmap.py +++ b/nmap.py @@ -37,12 +37,14 @@ Anything else to exit. def menuSelector(): menuChoice = input("Choose from above") - if menuChoice == "0": print("0.Selected Host Discoverer...") - elif menuChoice == "1": print("1.Selected Full Scan...") - elif menuChoice == "2": print("2.Selected TCP Connect...") - elif menuChoice == "3": print("3.Selected TCP Violation...") - elif menuChoice == "4": print("4.Selected Masscan...") - else: print("Exiting...") + switch = { + "0": "0.Selected Host Discoverer...", + "1": "1.Selected Full Scan...", + "2": "2.Selected TCP Connect...", + "3": "3.Selected TCP Violation...", + "4": "4.Selected Masscan..." + } + print(switch.get(menuChoice, "Exiting...")) return menuChoice def cmdList():