In Python, how do you get the position of an item in a list (using list.index) using fuzzy matching?
list.index
For example, how do I get the indexes of all fruit of t
with a function :
import re fruit_list = ['raspberry', 'apple', 'strawberry'] def grep(yourlist, yourstring): ide = [i for i, item in enumerate(yourlist) if re.search(yourstring, item)] return ide grep(fruit_list, "berry$")