Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Words Order-- read the conditions carefully solution in Clear category for Words Order by ChromeBrainer
def words_order(text: str, words: list) -> bool:
text=[i for i in text.split() if i in words]
words=[i for i in words if words.count(i)==1]
if len(words)<1 or len(text)<1:
return False
for i,j in [*zip(text,words)]:
if i==j:
return True
else:
return False
if __name__ == '__main__':
print("Example:")
print(words_order('hi world im here', ['wo', 'rld']))
# These "asserts" are used for self-checking and not for an auto-testing
assert words_order('hi world im here', ['world', 'here']) == True
assert words_order('hi world im here', ['here', 'world']) == False #here
assert words_order('hi world im here', ['world']) == True
assert words_order('hi world im here',
['world', 'here', 'hi']) == False #here
assert words_order('hi world im here',
['world', 'im', 'here']) == True
assert words_order('hi world im here',
['world', 'hi', 'here']) == False #here
assert words_order('hi world im here', ['world', 'world']) == False
assert words_order('hi world im here',
['country', 'world']) == False
assert words_order('hi world im here', ['wo', 'rld']) == False
assert words_order('', ['world', 'here']) == False
print("Coding complete? Click 'Check' to earn cool rewards!")
May 2, 2021