I am writing a program (which reads file from command line arguments) and some exceptions to handle. I have 2 exceptions:1)If the file i want to read doesn't exist in the path i should give an exception.2)If the format of the file i want to read doesn't match i should give another exception.
try:
f = open(sys.argv[2], 'r')
commands = [[line.split()] for line in f.readlines()]
f.close()
except FileNotFoundError:
print('Input file not found')
sys.exit()
For first exception i did this but i couldn't do the second one what should i do?
Note: Second exception means if i wrote x.txt in command line and if x.pptx exists i should give an exception like "Format is not correct".