Cortador de strings
Crie uma função que receba uma string (sem espaços) e uma lista de palavras, divida a string em palavras com base na lista e retorne a versão corretamente espaçada da string (uma frase). Se for encontrada uma parte da string que não esteja na lista de palavras, retorne "Cleaving stalled: Word not found".
Exemplos
word_list = ["about", "be", "hell", "if", "is", "it", "me", "other", "outer", "people", "the", "to", "up", "where"]
cleave("ifitistobeitisuptome", word_list) ➞ "if it is to be it is up to me"
cleave("hellisotherpeople", word_list) ➞ "hell is other people"
cleave("hellisotterpeople", word_list) ➞ "Cleaving stalled: Word not found"Notas
As palavras em word_list podem aparecer mais de uma vez na string. word_list é um guia de referência, como um dicionário que lista quais palavras são permitidas.