I have found some answers to this question before, but they seem to be obsolete for the current Python versions (or at least they don't work for me).
I want to check if a substring is contained in a list of strings. I only need the boolean result.
I found this solution:
word_to_check = 'or'
wordlist = ['yellow','orange','red']
result = any(word_to_check in word for word in worldlist)
From this code I would expect to get a True
value. If the word was "der", then the output should be False
.
However, the result is a generator function, and I can't find a way to get the True
value.
Any idea?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…