Advertisement
gruntfutuk

find_substr_in_list_of_str

Jul 18th, 2021
1,660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. def inside_search(strings: list, target: str) -> list:
  2.     if  not isinstance(strings, list):
  3.         raise ValueError('List expected to search')
  4.     if not isinstance(target, str):
  5.         raise ValueError('str expected for search')
  6.     result = []
  7.     for idx, string in enumerate(strings):
  8.         if not isinstance(string, str):
  9.             raise ValueError('only str objects expected in list to search')
  10.         if target in string:
  11.             result.append(idx)
  12.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement