Add entry to list and remove first one in Python
Posted
by
wagglewax
on Stack Overflow
See other posts from Stack Overflow
or by wagglewax
Published on 2012-04-14T17:22:38Z
Indexed on
2012/04/14
17:28 UTC
Read the original article
Hit count: 292
I have a list
of about 40 entries. And I frequently want to append an item to the start of the list (with id 0) and want to delete
the last
entry (with id 40) of the list.
how do i do this the best?
like:
(example with 5 entries)
[0] = "herp"
[1] = "derp"
[2] = "blah"
[3] = "what"
[4] = "da..."
after adding "wuggah" and deleting last it should be like:
[0] = "wuggah"
[1] = "herp"
[2] = "derp"
[3] = "blah"
[4] = "what"
or appending one and deleting first.
And I don't want to end up manually moving them one after another all of the entries to the next id.
© Stack Overflow or respective owner