Python Forum

Full Version: Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

Please go easy on me, I am new to this and I have never programmed/scripted before.

I am trying to learn python, and really struggling with it... can anyone help me with the following, that I can't seem to get running:
#################
# Main Function #
#################
def main():
print ('Welcome to the Network analysis tool')
userInput = input ('What would you like to do: ')

if userInput == '-p' or '--passive':
#then run in passive mode
# elif userInput == '-a' or '--active':
#then run in active mode
#else
# help():

main()

When I try to run it, I get:
File "./net_recon.py", line 27
main()
^
IndentationError: expected an indented block
I have indented main() and get the same thing....

Thanks, C.
Your if statement requires a code block to follow the colon, and you have just comment lines.
Add (indented) the command pass after that line. Then you can start working the other issues.

Also, in the future, please post code between python tags. Easy way to do that is copy the code, then tap the blue and yellow python icon in the editor on the website, then ctrl-v to paste
Thanks jefsummers!

It seems like no matter what I do, I cant get it to run (except when I comment out the if statement). Thanks for the heads up about the python code entry button.

I've tried:
userInput = input ('What would you like to do today: ')
if userInput == '-p' or '--passive':

userInput = input ('What would you like to do today: ')
if userInput == '-p' or '--passive':
and
userInput = input ('What would you like to do today: ')
if userInput == '-p' or '--passive':

Think Wall

[python=#!/usr/bin/python3

#################
# Help Function #
#################
#def help():
# print ("Please enter one of the following options:")
# print ("-p or --passive - for monitoring ARP traffic"
# print ("-a or --active - for active mode for ping sweep")
#help()

#################
# Main Function #
#################
def main():
print ('Welcome to the Network Recon tool')
userInput = input ('What would you like to do today: ')
if userInput == '-p' or '--passive':
#then run in passive mode
# elif userInput == '-a' or '--active':
#then run in active mode
#else
# help():

main()][/python]

I'll keep trying though.

Thanks, C.
def main():
  print ('Welcome to the Network Recon tool')
  userInput = input ('What would you like to do today: ')
  if userInput == '-p' or userInput == '--passive':
    pass
#then run in passive mode
# elif userInput == '-a' or '--active':
#then run in active mode
#else
# help():
Try making those 2 changes
(Oct-26-2020, 09:11 PM)jefsummers Wrote: [ -> ]
def main():
  print ('Welcome to the Network Recon tool')
  userInput = input ('What would you like to do today: ')
  if userInput == '-p' or userInput == '--passive':
    pass
#then run in passive mode
# elif userInput == '-a' or '--active':
#then run in active mode
#else
# help():
Try making those 2 changes

Perfect.

Thank you very much!!

C.