好的,我可以这样做:
[i for i in range(100) if i > 10 if i < 50]
或者我可以这样做:
[i for i in range(100) if i > 10 and i < 50]
但是,如果我试试这个:
def is_big(number):
number > 10
def is_small(number):
number < 50
我明白了:
[i for I in range(100) if is_big(I) and is_small(I)]
[]
[i for I in range(100) if is_big(I) if is_small(I)]
[]
答案 0 :(得分:0)
您的函数必须返回布尔结果
def is_big(number):
return number > 10
def is_small(number):
return number < 50
print [i for i in range(100) if is_big(i) and is_small(i)]