我是python新手。我试图创建一个函数,它将字符串和列表作为参数,并为字符串中找到的每个列表元素(这应该作为元组返回)返回一个布尔值。我曾尝试下面的代码列表元组返回python
def my_check(str1, list1):
words = str1.split()
x = 1
for l in range(len(list1)):
for i in range(len(words)):
if list1[l] == words[i]:
x = x+1
if (x > 1):
print(True)
x = 1
else:
print(False)
output = my_check('my name is ide3', ['is', 'my', 'no'])
print(output)
此代码输出
True
True
False
我怎样才能返回这个值作为一个元组
>>> output
(True, True, False)
任何想法表示赞赏。