I am having an issue with the following section of Python code:
def main():
file_name = sys.argv[1]
file = open(file_name, 'r')
l = []
for line in file:
if (len(l) == 4):
res = valid_data(l)
if (res == False):
print("The Data is InValid")
else:
print_data(l)
l = []
else:
l.append(line.strip())
if (l != []):
res = valid_data(l)
if (res == False):
print("The Data is InValid")
else:
print_data(l)
main()
Specifically, the error is as follows:
Traceback (most recent call last):
File "C:\Users\Desktop\44.py", line 194, in <module>
main()
File "C:\Users\Desktop\44.py", line 173, in main
information = sys.argv[1]
IndexError: list index out of range
The sys.argv might require an argument at the command line when running the script, but I'm not sure what the issue might be!