You have given a nested list. Write a program to extend it by adding the sublist ["h", "i", "j"] in such a way that it will look like the following list.
Given List:
list1 =["a","b",["c",["d","e",["f","g"],"k"],"l"],"m","n"]# sub list to add
sub_list =["h","i","j"]
Hint:
The given list is a nested list. Use indexing to locate the specified sublist item, then use the
extend()
method to add new items after it.Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer