sys.argv takes arguments at the shell command line when running a program. How do I make these arguments optional?

I know I can use try - except. But this forces you to insert either no extra arguments or all extra arguments, unless you nest more try - except which makes the code look much less readable.

Edit

Suppose I would want the following functionality, how do I implement this?

$ python program.py add Peter 
'Peter' was added to the list of names.

This add argument (and not --add) is optional such that

$ python program.py

just runs the program normally.

Edit
Report