Extend nested list by adding the sublist
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:
Expected Output:
['a', 'b', ['c', ['d', 'e', ['f', 'g', 'h', 'i', 'j'], 'k'], 'l'], 'm', 'n']
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