I would like to perform a double 'for' loop within a for-comprehension. However, I do not want to do it under the typical conditions, such as:
sentences = ['hello what are you doing?', 'trying to figure this out!']
[c for word in sentences for c in word]
Instead, I would like to perform this double iteration with condition, but in a for-comprehension:
words = ["snake", "porcupine", "lizard"]
substrings = ["sn", "o", "ke"]
new = []
for word in words:
for substr in substrings:
if substr in word:
new.append(word)
new = set(new)
print(new)
Any help is appreciated!
Just figured it out, nevermind. Simply use
any():