I have a list:
my_list = [\'abc-123\', \'def-456\', \'ghi-789\', \'abc-456\']
and want to search for items that contain the string \'
\'
I needed the list indices that correspond to a match as follows:
lst=['abc-123', 'def-456', 'ghi-789', 'abc-456'] [n for n, x in enumerate(lst) if 'abc' in x]
output
[0, 3]