为什么不能在迭代的同时修改列表和字典的大小
lst = ['张无忌','张三丰','张翠山','刘能','张嘉欣','刘嘉玲','刘老根']
new_lst = []
for el in lst:
if '张' in el:
new_lst.append(el)
for el in new_lst:
lst.remove(el)
print(lst)
lst = ['张无忌','张三丰','张翠山','刘能','张嘉欣','刘嘉玲','刘老根']
new_lst = []
for el in lst:
if '张' in el:
new_lst.append(el)
for el in new_lst:
lst.remove(el)
print(lst)