序列中插入元素

 

def insert_l(l, v, old_index, type='append'):
r = []
# p<len(l)
nl = len(l)
for i in range(nl):
if type == 'append':
r.append(l[i])
if i == old_index:
r.append(v)
elif type == 'before':
if i == old_index:
r.append(v)
r.append(l[i])
posted @ 2018-01-25 19:32  papering  阅读(209)  评论(0编辑  收藏  举报