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:]
टीपा लिहा
उत्तर
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
List
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
APPEARS IN
संबंधित प्रश्न
What will be the output of the following statement?
list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
What will be the output of the following statement?
list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
What will be the output of the following statement?
list1 = [1,2,3,4,5]
list1[len(list1)-1]
Write a program to find the number of times an element occurs in the list.