[Tutor] my own error code when no argument is sent

Danny Yoo dyoo at cs.wpi.edu
Tue Jun 17 05:05:50 CEST 2008

 when i execute my program without an argument i receive,
> infile = sys.argv[1]
> IndexError: list index out of range
> is there a way that i could suppress this and add my own error code

The direct way to handle this is to check the length of sys.argv
first.  sys.argv is a list, so you can ask the list for its length.
Do you know how to do that?

More information about the Tutor mailing list