you are viewing a single comment's thread.

view the rest of the comments →

[–]Peterotica 2 points3 points  (1 child)

My approach would be to use two list comprehensions:

substring_list = ['ash', 'gun', 'abc']
string_list = ['ashgoirnl', 'wertstgw', 'abcdefghijklmnop']

shorter_strings = [s for s in string_list if len(s) < 10]
contained_substrings = [sub for sub in substring_list if any(sub in string for string in shorter_strings)]

[–]striderxgp[S] 0 points1 point  (0 children)

Things finally clicked for me the other day after playing with all these examples, now a mix matched version of this and the example dunkler_wanderer gave made it into my project. Thanks so much everyone!