samedi 28 mars 2015

how to test if there is any word matched the string in Python

I want to write a python program to test if there are any phrase can match the string using python.



string ='I love my travel all over the world'
list =['I love','my travel','all over the world']


So I want to text if there are any one of list can match that string that can print 'I love' or 'my travel','all over the world'.



any(x in string for x in list)


Or I need to use text mining to solve the problem?


Aucun commentaire:

Enregistrer un commentaire