Jul-21-2019, 01:54 AM
if filename == "class1.txt" or filename == "class2.txt":But your professor has written, that you don't get credits for this.
Is only class1.txt and class2.txt allowed? Why? If only this two files are
allowed to access, why to write them out instead of using a kind of menu or
command line arguments.
You can use a list or tuple with filenames. Then you can check, if filename is in the iterable.
filename = 'something' allowed_filenames = ('class1.txt', 'class2.txt') if filename in allowed_filenames: #code # filename in allowed_filenames returns True, because 'something' is not in the tuple.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!