0

How to add value in existing list without using insert and extend operators

https://code.sololearn.com/cpN5kJQKwBwU/?ref=app

22nd Jan 2022, 11:18 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
5 Antworten
0
You could move before that the rest of a list after the insert point backwards.
22nd Jan 2022, 11:24 AM
JaScript
JaScript - avatar
0
I don't want to use insert operators
22nd Jan 2022, 11:28 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
There I mean without insert in this way list[point] = x
22nd Jan 2022, 11:51 AM
JaScript
JaScript - avatar
0
Show me demo
22nd Jan 2022, 11:51 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
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)
22nd Jan 2022, 12:46 PM
JaScript
JaScript - avatar