Ockonal Ockonal - 5 months ago 6x
Python Question

Check list of words in another string

I can do such thing in python:

list = ['one', 'two', 'three']
if 'some word' in list:

This will check if 'some word' exists in the list. But can I do reverse thing?

list = ['one', 'two', 'three']
if list in 'some one long two phrase three':

I have to check whether some words from array are in the string. I can do this using cycle but this way has more lines of code.

if any(word in 'some one long two phrase three' for word in list_):