0
How to add value in existing list without using insert and extend operators
5 Antworten
0
You could move before that the rest of a list after the insert point backwards.
0
I don't want to use insert operators
0
There I mean without insert in this way
list[point] = x
0
Show me demo
0
l1 = list(range(9))
print(l1)
p = 5
l2 = l1[:p]
l3 = [9]
l4 = l1[p:]
l5 = l2+l3+l4
print(l5)
#shortly code
l2 = l1[:p] + [9] + l1[p:]
print(l2)