How to find string in item of list python -


i need because want find str in list complete item.

my_list: looks like:

['mont saint martin, 42 rue de bordeaux', 'mont de marsan, 100 avenue pierre de coubertin', 'lyon, 56 rue du docteur alb\xc3\xa9ric pont', 'lille, 90 rue d\xe2\x80\x99arras', 'lyon, 2 all\xc3\xa9e des fleurs'] 

str: looks like:

"saint" or "de"

expected list after processing want check before ',':

['mont saint martin'] 

or str = "de"

['mont de marsan'] 

i have try with:

new = filter(lambda x: x.my_list == str, x)[0] 

thanks help.

cities = [w.split(',')[0] w in my_list] term = "de" results = [city city in cities if term in city.lower()] 

Comments