Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python find word in list

ls = ['Hello from AskPython', 'Hello', 'Hello boy!', 'Hi']
 
# The second parameter is the input iterable
# The filter() applies the lambda to the iterable
# and only returns all matches where the lambda evaluates
# to true
filter_object = filter(lambda a: 'AskPython' in a, ls)
 
# Convert the filter object to list
print(list(filter_object))
Source by www.askpython.com #
 
PREVIOUS NEXT
Tagged: #python #find #word #list
ADD COMMENT
Topic
Name
2+5 =