Advertisements
Advertisements
प्रश्न
What will be the output of the following statement?
list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]टीपा लिहा
Advertisements
उत्तर
The statement in line 2 has a negative step size. This means that the list will be traversed in reversed order with step size 2.
OUTPUT: [10, 8, 6, 4, 2]
The statement in line 3 will print the complete list. i.e. [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shaalaa.com
Lists in Python
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
