如果第一個字符串中的字母也包含在第二個字符串中,我希望能夠返回True
。例如,only_uses_letters_from("boffo","foobar")
應返回True
。以下是我迄今爲止:在python中區分字符串
def only_uses_letters_from(x, y):
"""returns true if the first string only contains characters that are also in the second string
str, str -> str"""
for letter in x:
if x in y:
return True
else:
return False
應該是'海峽,海峽 - > bool' BTW ... – 2015-02-09 01:11:01