Reputation: 737
I have a directory with the following sample filenames:
Apples.xlsx
Bananas.xlsx
Apples.docs
Pears.xlsx
I’m trying to form a list of only .xlsx files with either Apples or Bananas in the filename.
Tried this:
If (“Apples” or “Bananas”) and “.xlsx” in filename:
Do something
But the resulting list of files is:
Apples.xlsx
Bananas.xlsx
Pears.xlsx
What an I missing? Something rudimentary no doubt but Google and SO suggestions are not yielding the expected result:
Apples.xlsx
Bananas.xlsx
Upvotes: 0
Views: 30
Reputation: 2704
Your condition is not correct.
if ("Apples" in filename or "Banana" in filename) and “.xlsx” in filename:
Do something
Here you checked all the conditions. In your answer, you did ("apples" or "banana") which is true, and you checked if true in filename so the answer was not correct.
Upvotes: 1