How to use any generators to check a string is part of a list of other strings?
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?'
from Recent Questions - Stack Overflow https://ift.tt/3po9jKy
https://ift.tt/eA8V8J
Comments
Post a Comment