#终极版本
course=['javapython','cpython','pypython','lyk']
# def sb_show(n):
# return n.endswith('sb')
#--->lambda n:n.endswith('sb')
def filter_test(func,array):
ret=[]
for p in array:
if not func(p):
ret.append(p)
return ret
res=filter_test(lambda n:n.endswith('python'),course)
print(res)
'''
['lyk']
'''
#filter函数
course=['javapython','cpython','pypython','lyk']
print(filter(lambda n:not n.endswith('python'),course))
res=filter(lambda n:not n.endswith('python'),course)
print(list(res))
print(list(filter(lambda n:not n.endswith('python'),course)))
'''
<filter object at 0x0000000004E7B940>
['lyk']
['lyk']
'''