You can use any
function, like this
>>> any(item in input_string for item in my_list)
any
will return True
if the condition (item in input_string
) is satisfied atleast once. In this case, it iterates through my_list
and checks if the current item is in the input_string
with the in
operator. If any of the items in my_list
is in the input_string
, it will return True