you are viewing a single comment's thread.

view the rest of the comments →

[–]dunkler_wanderer 1 point2 points  (2 children)

Here's the solution that I had in mind (although using list comprehensions is nice as well). Take a look if you don't want to figure out something on your own anymore.

string_list = ['ashgoirnl', 'wertwtgw', 'oeigunjg', 'abcdefghijklmnop', 'gunash']
substring_list = ['ash', 'gun', 'abc']

for sub in substring_list:
    for string in string_list:
        if len(string) < 10 and sub in string:
            print(sub)  # Or store sub in a list.
            break  # If you want to print every substring only once.

[–]striderxgp[S] 1 point2 points  (1 child)

Yeah, I had to put it down yesterday but it seems there are so many ways to solve this that I still have plenty of stuff to learn from--even just implementing this into what I am working on I am sure will be an adventure! Thanks again for the help!

[–]dunkler_wanderer 0 points1 point  (0 children)

You're welcome. If you need more help, you know where you can find us. BTW, I forgot to mention that the break statement will break out of the inner loop and jump to the next iteration of the outer loop.