How to print last deleted element from the list?

l=[1,2,3,4]
del l[0]
print(l)
#del l[0]
#want to print this number whenever it will be deleted from the list

How to print last deleted element from the list ?

>Solution :

The function pop returns and removes an item of the list. So you could do this instead:

l=[1,2,3,4]
print(l.pop(0))

Leave a Reply