how to find a word in list python

Solutions on MaxInterview for how to find a word in list python by the best coders in the world

showing results for - "how to find a word in list python"
Niklas
16 Jan 2017
1keyword_list = ['motorcycle', 'bike', 'cycle', 'dirtbike']
2
3if any(word in all_text for word in keyword_list):
4    print 'found one of em'
Irene
30 Mar 2020
1ls = ['Hello from AskPython', 'Hello', 'Hello boy!', 'Hi']
2 
3matches = [match for match in ls if "Hello" in match]
4 
5print(matches)
6
Darcy
25 Jan 2016
1ls = ['Hello from AskPython', 'Hello', 'Hello boy!', 'Hi']
2 
3# The second parameter is the input iterable
4# The filter() applies the lambda to the iterable
5# and only returns all matches where the lambda evaluates
6# to true
7filter_object = filter(lambda a: 'AskPython' in a, ls)
8 
9# Convert the filter object to list
10print(list(filter_object))
11