Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Words Order by realidad.optica
def words_order(text: str, words: list) -> bool:
for i in words: #Si una palabra esta repetida en words retorna False.
if words.count(i) > 1:
return False
for i in text: #En textos con puntos, comas, ... ,
if not i.isalpha() and not i ==" ": #los elimina y quedan solo las palabras y espacios.
i.pop(i)
text2 = []
text1 = text.split(" ") #Separa las palabras por los espacios y hace una lista con ellas
for i in text1:
if i in words and i not in text2: #recorre text1 y cada palabra que aparece tambiƩn en words
text2.append(i) #la agrega a text2 en el orden de aparición
return text2==words #compara text2 con words, si son iguales es True si no False
Aug. 9, 2021