Given a set of words in lowercase. Check if there are a couple of words in this set, such that one word ends with another (suffix or match).

For example: {"hi", "hello", "lo"} - "lo" is the ending of "hello", so the result is True.

def checkio(words_set): for w1 in words_set: for w2 in words_set: #как тут использовать .endswith()? if __name__ == '__main__': assert checkio({"hello", "lo", "he"}) == True, "helLO" assert checkio({"hello", "la", "hellow", "cow"}) == False, "hellow la cow" assert checkio({"walk", "duckwalk"}) == True, "duck to walk" assert checkio({"one"}) == False, "Only One" assert checkio({"helicopter", "li", "he"}) == False, "Only end" 

    1 answer 1

     def checkio(words_set): for w1 in words_set: for w2 in words_set: if w1.endswith(w2): if w1 != w2: return True return False