Given a List LST=[11,21,31,41,51,61,71,81,91,100]. Predict the output for following list slice
statements :
(i) LST[1:3] (ii) LST[2:] (iii) LST[::-1] (iv) LST[1:5:2]
Answers
Answered by
0
Answer:
(i) = [21,31]
(ii) = [31,41,51,61,71,81,91,100]
(iii) = [100, 91, 81, 71, 61, 51, 41, 31, 21, 11]
(iv) = [21, 41]
Explanation:
[1:3]=[1,2] (3 is not included)
[2:]=from index 2 to all elements
[::-1] = Reverse of list
[1:5:2] = consider values from index 1 to 4 with step 2 = [1,3]
Similar questions