I want to replace a sub-list from list a, with another sub-list. Something like this:
a
a=[1,3,5,10,13]
Lets say I want to take a sublist like:
a_sub=[3,5,10]
and replace it with
b_sub=[9,7]
so the final result will be
print(a) >>> [1,9,7,13]
Any suggestions?
In [39]: a=[1,3,5,10,13] In [40]: sub_list_start = 1 In [41]: sub_list_end = 3 In [42]: a[sub_list_start : sub_list_end+1] = [9,7] In [43]: a Out[43]: [1, 9, 7, 13]
Hope that helps
1.4m articles
1.4m replys
5 comments
57.0k users