+ 1
Please solve error
2 ответов
+ 1
q() is not defined
do not indent big=... if it is not part of the function.
0
ViShal Bhoi
Yes, your indentation is wrong, as Lisa said.
filter expects a function that returns a boolean. Either modify your function or use map instead.
a=[10,20,30,40,50,60,70,80,90]
def plus10(x):
return x+10
#map uses function with return value
ten_more = list(map(plus10, a))
print(ten_more)
def gt40(x):
return x>40
#filter uses function that return a boolean (True or False)
above_40 = list(filter(gt40, a))
print(above_40)
#does not work as expected
test1 = list(map(gt40, a))
print(test1)
#does not work at all
test2 = list(filter(plus10, a))
print(test2)