I want to use argparse
to get option to my program. Here is my sample program:
from argparse import ArgumentParser
parser = ArgumentParser()
print("enter the numbers:")
a=int(input("number 1:"))
b=int(input("number 2:"))
parser.add_argument('-a','--add')
parser.add_argument('-s','--sub')
options = parser.parse_args()
if options:
c=a+b
if options.d:
c=a-b
print(c)
it gives the output correctly if I use
python file.pu -a 1
But I don't want to give value like 1
in compilation. What I want is
python file.py -a
that performs addition.
python file.py -s
that performs subtraction.
How to change the code for it?