【发布时间】:2013-08-06 12:40:29
【问题描述】:
代码:
def find(string_list, search):
new_list = []
for i in string_list:
if search in i:
new_list.append(i)
print(new_list)
print(find(['she', 'sells', 'sea', 'shells', 'on', 'the', 'sea-shore'], 'he'))
返回:
['she', 'shells', 'the']
None
【问题讨论】:
-
函数的默认返回值为
None。从print(find(...删除打印调用 -
列表在函数中打印。而 None 是函数的结果。
标签: python string list python-3.x