# movie_person=['alxe','tom','jerry','man'] # def m_show(n): # return n.endswith('m') # def filter_test(array): #array indicates that the list is used as data, and the print does not start with m # ret = [] # for p in movie_person: # if not p.startswith( ' m ' ): # not starting with m # ret.append(p)# Let's append the movie that does not start with m to the ret list # return right # res =filter_test(lambda n:n.endswith( ' m ' ), movie_person)#function plus object list execution # print(res) # filter function movie_person=['alxe','tom','jerry','man'] # print(filter(lambda n:n.endswith('m'),movie_person)) print((filter(lambda n:not n.endswith('m'),movie_person))) res=filter(lambda n:not n.endswith('m'),movie_person) print(list(res))#list() list display
#filterfunction movie_person=['alxe','tom','jerry','man'] def filter_test(array): #array indicates that the list is used as data, and the print does not start with m ret = [] for p in movie_person: if not p.startswith( ' m ' ):# not starting with m ret.append(p)# Append movies that do not start with m to the ret list return right res = filter_test(movie_person)#function plus object list execution print(res) movie_person=['alxe','tom','jerry','man'] def filter_test(array): #array indicates that the list is used as data, and the print does not start with m ret = [] for p in movie_person: if not p.endswith( ' m ' ): #not m-terminated ret.append(p)# Append movies that do not start with m to the ret list return right res = filter_test(movie_person)#function plus object list execution print(res)