Use better variant to get the last element

This commit is contained in:
MG-5 2022-10-25 00:11:40 +02:00
parent 914881a104
commit 2c0fdb13c7

View file

@ -78,7 +78,7 @@ def main(*_args):
# we want the latest json file in given folder
filesList = [f for f in os.listdir(file_path) if os.path.isfile(os.path.join(file_path, f)) and f.endswith(".json")]
filesList.sort()
file_path = os.path.join(file_path, filesList[len(filesList) - 1])
file_path = os.path.join(file_path, filesList[-1])
else:
print("Please enter a valid json file or the directory containing the json file!")