lst = ['张无忌','张三丰','张翠山','刘能','张嘉欣','刘嘉玲','刘老根']
new_lst = []
for el in lst:
if '张' in el:
new_lst.append(el)
for el in new_lst:
lst.remove(el)
print(lst)
Why you can not modify the size of the lists and dictionaries at the same time iteration
Guess you like
Origin www.cnblogs.com/zyyhxbs/p/10994162.html
Recommended
Ranking