I have a program that needs input: program.py < test.txt
How would I make it so that the program will exit if it doesn't get a file input?
this is how I read the input:
def file():
global index
import sys
tempo = sys.stdin.readlines()
for element in tempo:
if(index == 1):
key_route.append(element.strip('\n').rstrip().lstrip().lower())
index = 5
else:
routes.append(element.strip('\n').rstrip().lstrip().lower())