Python 我想把我的函数转换成lambda

Python 我想把我的函数转换成lambda,python,lambda,Python,Lambda,我想将此函数转换为lambda,但idk我做错了什么 temperatures=[10,20,30,11,22,33] def check_weather(temp,low,high): if temp in range(low,high): return True else: return False print(list(filter(lambda weather,low,high: True if weather in range(low

我想将此函数转换为lambda,但idk我做错了什么

temperatures=[10,20,30,11,22,33]

def check_weather(temp,low,high):
    if temp in range(low,high):
        return True
    else:
        return False

print(list(filter(lambda weather,low,high: True if weather in range(low,high) else False,temperatures)))
错误是:

TypeError:()缺少2个必需的位置参数:“低”和“高”


你不需要羔羊。如果这是可能的,您可以将函数用作对象

def check_weather(temp,low,high):
    return low <= temp <= high

print(list(filter(check_weather, weathers)))
def检查天气(温度、低温、高温):

返回低值您必须首先分配低值和高值

您在哪里使用了
temp
?我假设
weather
这里是
temp
low
high
的值应该来自哪里?能否请您将预期的输出添加到问题中。基于布尔值返回
True
False
是不必要的复杂。只需返回布尔值本身。这是否回答了您的问题虽然函数有三个参数,但概念是相同的。-另外:。。。