if __name__ == "__main__":
file = sys.argv[1]
f = FST("q0")
#f.addState("1", True)
#f.addState("2", True)
#f.addState("3", True)
in line file = sys.argv[1]
getting this error. can anyone please help me out.
if __name__ == "__main__":
file = sys.argv[1]
f = FST("q0")
#f.addState("1", True)
#f.addState("2", True)
#f.addState("3", True)
in line file = sys.argv[1]
getting this error. can anyone please help me out.
The sys.argv
list is populated only when command line arguments to the script are present. sys.argv[0]
is the name of the script you are running. sys.argv[1]
will be the first command line argument passed to the script. You need to call your script like:
python SCRIPT_NAME FIRST_ARG
You're probably running your script without arguments while it expects at least one.
sys.argv
is the list of arguments given to the script. sys.argv[0]
is the script itself; sys.argv[1]
is the first actual argument. If you give no argument to the script, 1
is an out of range index.