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
Try:
fruit_list = ['raspberry', 'apple', 'strawberry'] [ i for i, word in enumerate(fruit_list) if word.endswith('berry') ]
returns:
[0, 2]
Replace endswith with a different logic according to your matching needs.
endswith