Issue
I have a list as following
List_a = [1, 0, 0, 0, 1, 1]
I want to insert [0, 3]
into index 1
.
How it should look like:
New_List_a = [1, [0,3], 0, 0, 1, 1]
Any ideas?
Solution
the basic approach is
List_a = [1, 0, 0, 0, 1, 1]
# New_List_a = [1, [0,3], 0, 0, 1, 1]
l=[]
l.append(List_a[1])
for i in range(0,len(List_a)):
if(i==1): # real signature unknown
l.append(3)
List_a[i]=l
break
or you can also do this
List_a = [1, 0, 0, 0, 1, 1]
List_a[1] = [List_a[1], 3]
print(List_a)
Answered By - shaknoah Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.