kind of strange request.
let's have following list:
[1,2,3]
and want something, say, number 9, pass through every index, following list of lists:
[[9,1,2,3], [1,9,2,3], [1,2,9,3], [1,2,3,9]]
any idea how easily? also, there name sort of thing?
edit: realize can following:
lists=[] in range(4): new_list = [1,2,3] new_list.insert(i,9) lists+=[new_list]
but consider inelegant. thoughts?
you like
l = [1,2,3] new_l = [l[:i] + [9] + l[i:] in range(len(l) + 1)]
Comments
Post a Comment