def check(seq, elem):
list1 = list(str(x) for x in seq)
return False if not elem in list1 else True
print(check([66, 101], 66))
print(check([78, 117, 110, 99, 104, 117, 107, 115], 8))
print(check([101, 45, 75, 105, 99, 107], 107))
print(check([80, 117, 115, 104, 45, 85, 112, 115], 45))
print(check(['t', 'e', 's', 't'], 'e'))
print(check(["what", "a", "great", "kata"], "kat"))
print(check([66, "codewars", 11, "alex loves pushups"], "alex loves pushups"))
print(check(["come", "on", 110, "2500", 10, '!', 7, 15], "Come"))
print(check(["when's", "the", "next", "Katathon?", 9, 7], "Katathon?"))
print(check([8, 7, 5, "bored", "of", "writing", "tests", 115], 45))
print(check(["anyone", "want", "to", "hire", "me?"], "me?"))
一个简单的真/假任务,但我不明白如果数组与字符串和数字混合,如何在函数中查找值?
我不确定我是否正确理解了您的问题,但这是我的版本
及其对您的示例的结果:
它?
Python 之禅要求简单 :-)