题目:
In this task, you are given a set of words in lower case. Check whether there is a pair of words, such that one word is the end of another (a suffix of another). For example: {“hi”, “hello”, “lo”} – “lo” is the end of “hello”, so the result is True.
Input: Words as a set of strings.
Output: True or False, as a boolean.
例子:
checkio({“hello”, “lo”, “he”}) == True
checkio({“hello”, “la”, “hellow”, “cow”}) == False
checkio({“walk”, “duckwalk”}) == True
checkio({“one”}) == False
checkio({“helicopter”, “li”, “he”}) == False
链接:
https://py.checkio.org/en/mission/end-of-other/
def checkio(words_set):
a = words_set
r = False
if len(a) > 1:
for i in a:
for j in a:
if j != i and j == i[len(i)-len(j):len(i)]:
r = True
return r