2

When an element from an array is deleted using del, is it possible to retrieve the deleted element..

del_ele = []
arr=[1,2,3,4,5,6,7,8,9,10]
del_ele.append(del arr[6])
1

2 Answers 2

9

Use the pop method.

del_ele.append(arr.pop(6))
Sign up to request clarification or add additional context in comments.

Comments

0

No, it's not possible. Quoting from (http://www.python.org/doc//current/reference/simple_stmts.html#del): Deletion of a name removes the binding of that name from the local or global namespace,...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.