if 'PASSED' in cell.value or 'FAILED' in cell.value or 'INVALID' in cell.value:
Test.append(6)
What is a more concise way to do this? I want to make it do something like
if cell.value in ('PASSED','INVALID', 'FAILED')
but that doesn't work
Use the any() function and a generator expression:
if any(s in cell.value for s in ('PASSED','INVALID', 'FAILED')):
This tests each string in turn, returning True as soon as a test passes.
'hello' in ( 'hello', 'world' ) #returns Truenot work for you? Are you sure thatcell.valueis a string ?cell.valueis a larger string which may contain any of those three strings.cell.valueis exactly one of those strings, but not ifcell.valuecontains such a string; e.g.cell.valueis a longer string like"The tests results were INVALID".'INVALID' in cell.valueis then true, but your test is not.