I have come across this:
item = someSortOfSelection() if item in myList: doMySpecialFunction(item)
but sometimes it does not work with
Check there are no additional/unwanted whites space in the items of the list of strings. That's a reason that can be interfering explaining the items cannot be found.