I am reading about any()
in python and I am not sure how to use it.
My case is as follows: Given two lists of server names, list A and list B, I need to check if any of the names from A matches to B.
I found these two questions that is similar to what I am trying to do:
- Check if multiple strings exist in another string
- How to check if a string contains an element from a list in Python
But I am not understanding the code of any()
very well. Is the below what I am supposed to do with the generator?
any(X in listA for Y in listB)
means 'If any item X
in listA
is truthty against each item Y
in listB
return true?'