import os
for file in ['a.txt', 'b.txt', 'c.txt']:
if not os.path.exists(os.getcwd() + '\\' + file):
print(fr'{file} is missing')
Basically, I would like to place a.txt, b.txt, c.txt into the os.path.exists function one by one, and then, inside the if clause, I would like to print the message with the file name included. I have no idea how to make it pythonic. I see people write "in" with "if" in one line, but I have no idea how to do that in my case, as I have a print function that uses the value "file" too.
Again, I want to make it efficient, pythonic.
forloop as you are trying to check if each file exists or not.if file in ('a.txt', 'b.txt', 'c.txt'):but that's testing something completely different.