I have a script where the user can input two date values for a date range to run my script. If they don't input two values, I want my script to run with a default date range. How can I do this?
Right now this is what I have:
parser = argparse.ArgumentParser()
parser.add_argument('start', type=str, help='Start date YYYY-MM-DD')
parser.add_argument('end', type=str, help='End date YYYY-MM-DD')
args = parser.parse_args()
start = args.start
stop = args.end
** if the two dates are invalid or not provided by user: **
start = '20220101'
stop = '20220416'
default=arg for theadd_argumentparser.add_argument('end', type=str, help='End date YYYY-MM-DD', default='2022-10-05)`startwithout using the defaultend, asmyscript 20220805will assume it was given a starting date.