Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Removing an element from a list by index without returning the deleted element

simply put, I just want an alternative to .pop that does not return the removed element and also takes an index for parameters.
To give an example, I enter this code:

[1, 2, 3].pop(0)

but it gives me this as an output:

[1]

what I want as an output is [2, 3] and not [1].
is there a simple way of doing this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can also use list slicing method.

print([1,2,3][1:])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading