Qus : Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?
Qusमान लीजिए कि लिस्ट 1 है [4, 2, 2, 4, 5, 2, 1, 0], निम्न में से कौन सा स्लाइसिंग ऑपरेशन के लिए करेक्ट सिन्टैक्स है?
A. print(list1[0]) B. print(list1[:2])
C. print(list1[:-2]) D. all of the mentioned
Solution
D. all of the mentioned
Explanation
Slicing is allowed in lists just as in the case of strings.