You have to use a Trie data structure to find the English words in a string. You can use a dict, but Trie is memory efficient.
- Create a Trie with all English words.
- Here is an example (not tested):
string = "BONJOURHELLOCIAO"
for i in range(len(string)): # start with first char
current_word = ""
for char in string[i:]: # check all next chars
current_word += char
if trie.search(current_word):
print(current_word) # each iteration prints a word with the same base
else:
if not current_word: # not a single word
continue
print(current_word)
current_word = "" # no more words with the same base