r/pythonhelp • u/[deleted] • Dec 01 '22
how to pass multiple flags in argparse?
I have these lines of code and im trying to pass something like ScriptName.py --naruto --goku
but its giving error of unexpected arguments. when I pass only one, for example only --naruto, then its working fine. any help on how to pass multiple flags in python?
parser.add_argument('--naruto', action='store_true')
parser.add_argument('--transformers', action='store_true')
parser.add_argument('--goku', action='store_true')
2
Upvotes
1
u/Goobyalus Dec 01 '22
How exactly are you running the script, and what is the complete error output?
This works as expected:
Output:
so maybe you're invoking the script in a weird way.