Advertisements
Advertisements
प्रश्न
What will be the output of the following code segment:
myList = [1,2,3,4,5,6,7,8,9,10]
del myList[::2]
print(myList)टीपा लिहा
Advertisements
उत्तर
The statement in line 2 will delete the elements from the start to the end of the list with step size 2. i.e it will delete elements starting from index 0, then index 2, index 4, index 6 … and so on. The output will be the remaining elements i.e. [2, 4, 6, 8, 10].
shaalaa.com
Lists Manipulation in Python
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
