Assignment
University
CollegeCourse
College Computer SciencePages
1
Academic year
2023
Avaiya Priyank
Views
0
p {margin: 0; padding: 0;} .ft00{font-size:21px;font-family:Cambria;color:#ff0000;} .ft01{font-size:21px;font-family:Arial;color:#ff0000;} .ft02{font-size:16px;font-family:Calibri;color:#000000;} .ft03{font-size:21px;line-height:28px;font-family:Cambria;color:#ff0000;} 8. Given a nested list extend it by adding the sub list ["h", "i", "j"] in such a way that it will look like the following list list1 = ["a", "b", ["c", ["d", "e", ["f", "g"], "k"], "l"], "m", "n"] Expected output: ['a', 'b', ['c', ['d', 'e', ['f', 'g', 'h', 'i', 'j'], 'k'], 'l'], 'm', 'n'] >>> list1 = ["a", "b", ["c", ["d", "e", ["f", "g"], "k"], "l"], "m", "n"] >>> list2 = ["h", "i", "j"] >>> list1[2][1][2].extend(list2) >>> print(list1) ['a', 'b', ['c', ['d', 'e', ['f', 'g', 'h', 'i', 'j'], 'k'], 'l'], 'm', 'n']
Extending Nested List: Incorporating Sub List
Please or to post comments