So starting with a list of strings, as below
string_list = [\'rest\', \'resting\', \'look\', \'looked\', \'it\', \'spit\']
I wan
Here's a possible solution:
string_list = ['rest', 'resting', 'look', 'looked', 'it', 'spit']
def string_set(string_list):
return set(i for i in string_list
if not any(i in s for s in string_list if i != s))
print(string_set(string_list))
prints out:
set(['looked', 'resting', 'spit'])
Note I create a set (using a generator expression) to remove possibly duplicated words as it appears that order does not matter.