def delete(word_list):
if word_list:
for i in word_list:
if i[0] == 'stop':
word_list.remove(i)
print delete([('noun', 'bear'),('stop', 'the')])
请各位帮忙看看,多谢
def delete(word_list):
if word_list:
for i in word_list:
if i[0] == 'stop':
word_list.remove(i)
print delete([('noun', 'bear'),('stop', 'the')])
请各位帮忙看看,多谢
delete函数没有返回值,所以是None。改成这样:
def delete(word_list):
if word_list:
for i in word_list:
if i[0] == 'stop':
word_list.remove(i)
return word_list
print delete([('noun', 'bear'),('stop', 'the')])