What is the purpose of the del operator and pop method? Try deleting a slice.

Question :

What is the purpose of the del operator and pop method? Try deleting a slice.

del operator is used to remove an individual item, or to remove all items identified by a slice. It is to be used as per syntax given below –

>>>del List[index]

>>>del List[start:stop]

pop method is used to remove single element, not list slices. The pop() method removes an individual item and returns it. Its syntax is –

>>>a=List.pop() #this will remove last item and deleted item will be assigned to a.

>>>a=List[10] # this will remove the ite at index 10 and deleted item will be assigned to a.


Similar Questions


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz