Basic List Operations
Write the function definition for the function 'List_Op' which takes 2 parameters 'Mylist' and 'Mylist2' both of which are LIST of INTEGERS
Do as per the following to get the expected output:
1.Print 'Mylist'
2.Print the 1st element of 'Mylist'
3.Print the Last element of 'Mylist'
4.Add '3' as the Last element of 'Mylist'
5.Change the 4th element of 'Mylist' into '60'
6.Print 'Mylist' again
7.Print from the '2nd' element to the '5th' element of 'Mylist'
8.Append 'Mylist2' to 'Mylist'
9.Print 'Mylist' again
10.Extend 'Mylist' using 'Mylist2'
11.Print 'Mylist' again
12.Remove the Last element of 'Mylist'
13.Print 'Mylist' again
14.Print 'Length' of 'Mylist'
Input Format for Custom Testing
- The first line contains an integer n1, the size of the Mylist
Each of the next n1 lines contains an Mylist[i] where 0 ≤ i < n1.
- The next line contains an integer n2, the size of the Mylist2.
Each of the next n2 lines contains an Mylist2[i] where 0 ≤ i < n2.
Sample Test Case 1
Sample Input
STDIN Function ----- -------- 5 → Mylist[] Size n1 = 5 1 → Mylist[] = [ 1, 2, 3, 4, 5 ] 2 3 4 5 3 → Mylist2[] Size n2 = 3 6 → Mylist2[] = [6, 7, 8] 7 8
Sample Output
[1, 2, 3, 4, 5] 2 5 [1, 2, 3, 60, 5, 3] [2, 3, 60, 5] [1, 2, 3, 60, 5, 3, [6, 7, 8]] [1, 2, 3, 60, 5, 3, [6, 7, 8], 6, 7, 8] [1, 2, 3, 60, 5, 3, [6, 7, 8], 6, 7] 9
Comments
Post a Comment